From f71370ad817b373401bd1d6a4454a9123c2369d6 Mon Sep 17 00:00:00 2001 From: Conghui Chen Date: Thu, 29 Nov 2018 08:12:32 +0800 Subject: [PATCH] dm: storage: rename delete to discard To keep consistent with kernal code, change delete to discard. Tracked-On: #2011 Signed-off-by: Conghui Chen Reviewed-by: Shuo A Liu Acked-by: Yu Wang --- devicemodel/hw/block_if.c | 24 ++++++++++++------------ devicemodel/hw/pci/ahci.c | 10 +++++----- devicemodel/include/block_if.h | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/devicemodel/hw/block_if.c b/devicemodel/hw/block_if.c index 76001108f..1a8d5cf52 100644 --- a/devicemodel/hw/block_if.c +++ b/devicemodel/hw/block_if.c @@ -75,7 +75,7 @@ enum blockop { BOP_READ, BOP_WRITE, BOP_FLUSH, - BOP_DELETE + BOP_DISCARD }; enum blockstat { @@ -99,7 +99,7 @@ struct blockif_ctxt { int magic; int fd; int isblk; - int candelete; + int candiscard; int rdonly; off_t size; int sub_file_assign; @@ -165,7 +165,7 @@ blockif_enqueue(struct blockif_ctxt *bc, struct blockif_req *breq, switch (op) { case BOP_READ: case BOP_WRITE: - case BOP_DELETE: + case BOP_DISCARD: off = breq->offset; for (i = 0; i < breq->iovcnt; i++) off += breq->iov[i].iov_len; @@ -270,9 +270,9 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be) if (fsync(bc->fd)) err = errno; break; - case BOP_DELETE: + case BOP_DISCARD: /* only used by AHCI */ - if (!bc->candelete) + if (!bc->candiscard) err = EOPNOTSUPP; else if (bc->rdonly) err = EROFS; @@ -419,7 +419,7 @@ blockif_open(const char *optstr, const char *ident) /* struct diocgattr_arg arg; */ off_t size, psectsz, psectoff; int fd, i, sectsz; - int writeback, ro, candelete, ssopt, pssopt; + int writeback, ro, candiscard, ssopt, pssopt; long sz; long long b; int err_code = -1; @@ -517,7 +517,7 @@ blockif_open(const char *optstr, const char *ident) size = sbuf.st_size; sectsz = DEV_BSIZE; psectsz = psectoff = 0; - candelete = 0; + candiscard = 0; if (S_ISBLK(sbuf.st_mode)) { /* get size */ @@ -612,7 +612,7 @@ blockif_open(const char *optstr, const char *ident) bc->magic = BLOCKIF_SIG; bc->fd = fd; bc->isblk = S_ISBLK(sbuf.st_mode); - bc->candelete = candelete; + bc->candiscard = candiscard; bc->rdonly = ro; bc->size = size; bc->sectsz = sectsz; @@ -697,10 +697,10 @@ blockif_flush(struct blockif_ctxt *bc, struct blockif_req *breq) } int -blockif_delete(struct blockif_ctxt *bc, struct blockif_req *breq) +blockif_discard(struct blockif_ctxt *bc, struct blockif_req *breq) { assert(bc->magic == BLOCKIF_SIG); - return blockif_request(bc, breq, BOP_DELETE); + return blockif_request(bc, breq, BOP_DISCARD); } int @@ -900,10 +900,10 @@ blockif_is_ro(struct blockif_ctxt *bc) } int -blockif_candelete(struct blockif_ctxt *bc) +blockif_candiscard(struct blockif_ctxt *bc) { assert(bc->magic == BLOCKIF_SIG); - return bc->candelete; + return bc->candiscard; } uint8_t diff --git a/devicemodel/hw/pci/ahci.c b/devicemodel/hw/pci/ahci.c index 6ce94bb4a..e2f7b2d84 100644 --- a/devicemodel/hw/pci/ahci.c +++ b/devicemodel/hw/pci/ahci.c @@ -874,7 +874,7 @@ next: if (ncq && first) ahci_write_fis_d2h_ncq(p, slot); - err = blockif_delete(p->bctx, breq); + err = blockif_discard(p->bctx, breq); assert(err == 0); } @@ -943,7 +943,7 @@ ahci_handle_read_log(struct ahci_port *p, int slot, uint8_t *cfis) memcpy(buf8, p->err_cfis, sizeof(p->err_cfis)); ahci_checksum(buf8, sizeof(buf)); } else if (cfis[4] == 0x13) { /* SATA NCQ Send and Receive Log */ - if (blockif_candelete(p->bctx) && !blockif_is_ro(p->bctx)) { + if (blockif_candiscard(p->bctx) && !blockif_is_ro(p->bctx)) { buf[0x00] = 1; /* SFQ DSM supported */ buf[0x01] = 1; /* SFQ DSM TRIM supported */ } @@ -971,12 +971,12 @@ handle_identify(struct ahci_port *p, int slot, uint8_t *cfis) } else { uint16_t buf[256]; uint64_t sectors; - int sectsz, psectsz, psectoff, candelete, ro; + int sectsz, psectsz, psectoff, candiscard, ro; uint16_t cyl; uint8_t sech, heads; ro = blockif_is_ro(p->bctx); - candelete = blockif_candelete(p->bctx); + candiscard = blockif_candiscard(p->bctx); sectsz = blockif_sectsz(p->bctx); sectors = blockif_size(p->bctx) / sectsz; blockif_chs(p->bctx, &cyl, &heads, &sech); @@ -1036,7 +1036,7 @@ handle_identify(struct ahci_port *p, int slot, uint8_t *cfis) buf[101] = (sectors >> 16); buf[102] = (sectors >> 32); buf[103] = (sectors >> 48); - if (candelete && !ro) { + if (candiscard && !ro) { buf[69] |= ATA_SUPPORT_RZAT | ATA_SUPPORT_DRAT; buf[105] = 1; buf[169] = ATA_SUPPORT_DSM_TRIM; diff --git a/devicemodel/include/block_if.h b/devicemodel/include/block_if.h index 6826618e2..c02fb62f3 100644 --- a/devicemodel/include/block_if.h +++ b/devicemodel/include/block_if.h @@ -59,11 +59,11 @@ int blockif_sectsz(struct blockif_ctxt *bc); void blockif_psectsz(struct blockif_ctxt *bc, int *size, int *off); int blockif_queuesz(struct blockif_ctxt *bc); int blockif_is_ro(struct blockif_ctxt *bc); -int blockif_candelete(struct blockif_ctxt *bc); +int blockif_candiscard(struct blockif_ctxt *bc); int blockif_read(struct blockif_ctxt *bc, struct blockif_req *breq); int blockif_write(struct blockif_ctxt *bc, struct blockif_req *breq); int blockif_flush(struct blockif_ctxt *bc, struct blockif_req *breq); -int blockif_delete(struct blockif_ctxt *bc, struct blockif_req *breq); +int blockif_discard(struct blockif_ctxt *bc, struct blockif_req *breq); int blockif_cancel(struct blockif_ctxt *bc, struct blockif_req *breq); int blockif_close(struct blockif_ctxt *bc); uint8_t blockif_get_wce(struct blockif_ctxt *bc);