dm: storage: rename delete to discard

To keep consistent with kernal code, change delete to discard.

Tracked-On: #2547
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Conghui Chen 2018-11-29 08:12:32 +08:00 committed by wenlingz
parent 0cdc13fa0e
commit c96e33ca64
3 changed files with 19 additions and 19 deletions

View File

@ -75,7 +75,7 @@ enum blockop {
BOP_READ, BOP_READ,
BOP_WRITE, BOP_WRITE,
BOP_FLUSH, BOP_FLUSH,
BOP_DELETE BOP_DISCARD
}; };
enum blockstat { enum blockstat {
@ -99,7 +99,7 @@ struct blockif_ctxt {
int magic; int magic;
int fd; int fd;
int isblk; int isblk;
int candelete; int candiscard;
int rdonly; int rdonly;
off_t size; off_t size;
int sub_file_assign; int sub_file_assign;
@ -165,7 +165,7 @@ blockif_enqueue(struct blockif_ctxt *bc, struct blockif_req *breq,
switch (op) { switch (op) {
case BOP_READ: case BOP_READ:
case BOP_WRITE: case BOP_WRITE:
case BOP_DELETE: case BOP_DISCARD:
off = breq->offset; off = breq->offset;
for (i = 0; i < breq->iovcnt; i++) for (i = 0; i < breq->iovcnt; i++)
off += breq->iov[i].iov_len; off += breq->iov[i].iov_len;
@ -270,9 +270,9 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be)
if (fsync(bc->fd)) if (fsync(bc->fd))
err = errno; err = errno;
break; break;
case BOP_DELETE: case BOP_DISCARD:
/* only used by AHCI */ /* only used by AHCI */
if (!bc->candelete) if (!bc->candiscard)
err = EOPNOTSUPP; err = EOPNOTSUPP;
else if (bc->rdonly) else if (bc->rdonly)
err = EROFS; err = EROFS;
@ -419,7 +419,7 @@ blockif_open(const char *optstr, const char *ident)
/* struct diocgattr_arg arg; */ /* struct diocgattr_arg arg; */
off_t size, psectsz, psectoff; off_t size, psectsz, psectoff;
int fd, i, sectsz; int fd, i, sectsz;
int writeback, ro, candelete, ssopt, pssopt; int writeback, ro, candiscard, ssopt, pssopt;
long sz; long sz;
long long b; long long b;
int err_code = -1; int err_code = -1;
@ -517,7 +517,7 @@ blockif_open(const char *optstr, const char *ident)
size = sbuf.st_size; size = sbuf.st_size;
sectsz = DEV_BSIZE; sectsz = DEV_BSIZE;
psectsz = psectoff = 0; psectsz = psectoff = 0;
candelete = 0; candiscard = 0;
if (S_ISBLK(sbuf.st_mode)) { if (S_ISBLK(sbuf.st_mode)) {
/* get size */ /* get size */
@ -612,7 +612,7 @@ blockif_open(const char *optstr, const char *ident)
bc->magic = BLOCKIF_SIG; bc->magic = BLOCKIF_SIG;
bc->fd = fd; bc->fd = fd;
bc->isblk = S_ISBLK(sbuf.st_mode); bc->isblk = S_ISBLK(sbuf.st_mode);
bc->candelete = candelete; bc->candiscard = candiscard;
bc->rdonly = ro; bc->rdonly = ro;
bc->size = size; bc->size = size;
bc->sectsz = sectsz; bc->sectsz = sectsz;
@ -697,10 +697,10 @@ blockif_flush(struct blockif_ctxt *bc, struct blockif_req *breq)
} }
int 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); assert(bc->magic == BLOCKIF_SIG);
return blockif_request(bc, breq, BOP_DELETE); return blockif_request(bc, breq, BOP_DISCARD);
} }
int int
@ -900,10 +900,10 @@ blockif_is_ro(struct blockif_ctxt *bc)
} }
int int
blockif_candelete(struct blockif_ctxt *bc) blockif_candiscard(struct blockif_ctxt *bc)
{ {
assert(bc->magic == BLOCKIF_SIG); assert(bc->magic == BLOCKIF_SIG);
return bc->candelete; return bc->candiscard;
} }
uint8_t uint8_t

View File

@ -874,7 +874,7 @@ next:
if (ncq && first) if (ncq && first)
ahci_write_fis_d2h_ncq(p, slot); ahci_write_fis_d2h_ncq(p, slot);
err = blockif_delete(p->bctx, breq); err = blockif_discard(p->bctx, breq);
assert(err == 0); 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)); memcpy(buf8, p->err_cfis, sizeof(p->err_cfis));
ahci_checksum(buf8, sizeof(buf)); ahci_checksum(buf8, sizeof(buf));
} else if (cfis[4] == 0x13) { /* SATA NCQ Send and Receive Log */ } 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[0x00] = 1; /* SFQ DSM supported */
buf[0x01] = 1; /* SFQ DSM TRIM supported */ buf[0x01] = 1; /* SFQ DSM TRIM supported */
} }
@ -971,12 +971,12 @@ handle_identify(struct ahci_port *p, int slot, uint8_t *cfis)
} else { } else {
uint16_t buf[256]; uint16_t buf[256];
uint64_t sectors; uint64_t sectors;
int sectsz, psectsz, psectoff, candelete, ro; int sectsz, psectsz, psectoff, candiscard, ro;
uint16_t cyl; uint16_t cyl;
uint8_t sech, heads; uint8_t sech, heads;
ro = blockif_is_ro(p->bctx); ro = blockif_is_ro(p->bctx);
candelete = blockif_candelete(p->bctx); candiscard = blockif_candiscard(p->bctx);
sectsz = blockif_sectsz(p->bctx); sectsz = blockif_sectsz(p->bctx);
sectors = blockif_size(p->bctx) / sectsz; sectors = blockif_size(p->bctx) / sectsz;
blockif_chs(p->bctx, &cyl, &heads, &sech); 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[101] = (sectors >> 16);
buf[102] = (sectors >> 32); buf[102] = (sectors >> 32);
buf[103] = (sectors >> 48); buf[103] = (sectors >> 48);
if (candelete && !ro) { if (candiscard && !ro) {
buf[69] |= ATA_SUPPORT_RZAT | ATA_SUPPORT_DRAT; buf[69] |= ATA_SUPPORT_RZAT | ATA_SUPPORT_DRAT;
buf[105] = 1; buf[105] = 1;
buf[169] = ATA_SUPPORT_DSM_TRIM; buf[169] = ATA_SUPPORT_DSM_TRIM;

View File

@ -59,11 +59,11 @@ int blockif_sectsz(struct blockif_ctxt *bc);
void blockif_psectsz(struct blockif_ctxt *bc, int *size, int *off); void blockif_psectsz(struct blockif_ctxt *bc, int *size, int *off);
int blockif_queuesz(struct blockif_ctxt *bc); int blockif_queuesz(struct blockif_ctxt *bc);
int blockif_is_ro(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_read(struct blockif_ctxt *bc, struct blockif_req *breq);
int blockif_write(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_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_cancel(struct blockif_ctxt *bc, struct blockif_req *breq);
int blockif_close(struct blockif_ctxt *bc); int blockif_close(struct blockif_ctxt *bc);
uint8_t blockif_get_wce(struct blockif_ctxt *bc); uint8_t blockif_get_wce(struct blockif_ctxt *bc);