Skip to content

Commit f71370a

Browse files
conghuic23wenlingz
authored andcommitted
dm: storage: rename delete to discard
To keep consistent with kernal code, change delete to discard. Tracked-On: #2011 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>
1 parent 36863a0 commit f71370a

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

devicemodel/hw/block_if.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ enum blockop {
7575
BOP_READ,
7676
BOP_WRITE,
7777
BOP_FLUSH,
78-
BOP_DELETE
78+
BOP_DISCARD
7979
};
8080

8181
enum blockstat {
@@ -99,7 +99,7 @@ struct blockif_ctxt {
9999
int magic;
100100
int fd;
101101
int isblk;
102-
int candelete;
102+
int candiscard;
103103
int rdonly;
104104
off_t size;
105105
int sub_file_assign;
@@ -165,7 +165,7 @@ blockif_enqueue(struct blockif_ctxt *bc, struct blockif_req *breq,
165165
switch (op) {
166166
case BOP_READ:
167167
case BOP_WRITE:
168-
case BOP_DELETE:
168+
case BOP_DISCARD:
169169
off = breq->offset;
170170
for (i = 0; i < breq->iovcnt; i++)
171171
off += breq->iov[i].iov_len;
@@ -270,9 +270,9 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be)
270270
if (fsync(bc->fd))
271271
err = errno;
272272
break;
273-
case BOP_DELETE:
273+
case BOP_DISCARD:
274274
/* only used by AHCI */
275-
if (!bc->candelete)
275+
if (!bc->candiscard)
276276
err = EOPNOTSUPP;
277277
else if (bc->rdonly)
278278
err = EROFS;
@@ -419,7 +419,7 @@ blockif_open(const char *optstr, const char *ident)
419419
/* struct diocgattr_arg arg; */
420420
off_t size, psectsz, psectoff;
421421
int fd, i, sectsz;
422-
int writeback, ro, candelete, ssopt, pssopt;
422+
int writeback, ro, candiscard, ssopt, pssopt;
423423
long sz;
424424
long long b;
425425
int err_code = -1;
@@ -517,7 +517,7 @@ blockif_open(const char *optstr, const char *ident)
517517
size = sbuf.st_size;
518518
sectsz = DEV_BSIZE;
519519
psectsz = psectoff = 0;
520-
candelete = 0;
520+
candiscard = 0;
521521

522522
if (S_ISBLK(sbuf.st_mode)) {
523523
/* get size */
@@ -612,7 +612,7 @@ blockif_open(const char *optstr, const char *ident)
612612
bc->magic = BLOCKIF_SIG;
613613
bc->fd = fd;
614614
bc->isblk = S_ISBLK(sbuf.st_mode);
615-
bc->candelete = candelete;
615+
bc->candiscard = candiscard;
616616
bc->rdonly = ro;
617617
bc->size = size;
618618
bc->sectsz = sectsz;
@@ -697,10 +697,10 @@ blockif_flush(struct blockif_ctxt *bc, struct blockif_req *breq)
697697
}
698698

699699
int
700-
blockif_delete(struct blockif_ctxt *bc, struct blockif_req *breq)
700+
blockif_discard(struct blockif_ctxt *bc, struct blockif_req *breq)
701701
{
702702
assert(bc->magic == BLOCKIF_SIG);
703-
return blockif_request(bc, breq, BOP_DELETE);
703+
return blockif_request(bc, breq, BOP_DISCARD);
704704
}
705705

706706
int
@@ -900,10 +900,10 @@ blockif_is_ro(struct blockif_ctxt *bc)
900900
}
901901

902902
int
903-
blockif_candelete(struct blockif_ctxt *bc)
903+
blockif_candiscard(struct blockif_ctxt *bc)
904904
{
905905
assert(bc->magic == BLOCKIF_SIG);
906-
return bc->candelete;
906+
return bc->candiscard;
907907
}
908908

909909
uint8_t

devicemodel/hw/pci/ahci.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ ahci_handle_dsm_trim(struct ahci_port *p, int slot, uint8_t *cfis,
874874
if (ncq && first)
875875
ahci_write_fis_d2h_ncq(p, slot);
876876

877-
err = blockif_delete(p->bctx, breq);
877+
err = blockif_discard(p->bctx, breq);
878878
assert(err == 0);
879879
}
880880

@@ -943,7 +943,7 @@ ahci_handle_read_log(struct ahci_port *p, int slot, uint8_t *cfis)
943943
memcpy(buf8, p->err_cfis, sizeof(p->err_cfis));
944944
ahci_checksum(buf8, sizeof(buf));
945945
} else if (cfis[4] == 0x13) { /* SATA NCQ Send and Receive Log */
946-
if (blockif_candelete(p->bctx) && !blockif_is_ro(p->bctx)) {
946+
if (blockif_candiscard(p->bctx) && !blockif_is_ro(p->bctx)) {
947947
buf[0x00] = 1; /* SFQ DSM supported */
948948
buf[0x01] = 1; /* SFQ DSM TRIM supported */
949949
}
@@ -971,12 +971,12 @@ handle_identify(struct ahci_port *p, int slot, uint8_t *cfis)
971971
} else {
972972
uint16_t buf[256];
973973
uint64_t sectors;
974-
int sectsz, psectsz, psectoff, candelete, ro;
974+
int sectsz, psectsz, psectoff, candiscard, ro;
975975
uint16_t cyl;
976976
uint8_t sech, heads;
977977

978978
ro = blockif_is_ro(p->bctx);
979-
candelete = blockif_candelete(p->bctx);
979+
candiscard = blockif_candiscard(p->bctx);
980980
sectsz = blockif_sectsz(p->bctx);
981981
sectors = blockif_size(p->bctx) / sectsz;
982982
blockif_chs(p->bctx, &cyl, &heads, &sech);
@@ -1036,7 +1036,7 @@ handle_identify(struct ahci_port *p, int slot, uint8_t *cfis)
10361036
buf[101] = (sectors >> 16);
10371037
buf[102] = (sectors >> 32);
10381038
buf[103] = (sectors >> 48);
1039-
if (candelete && !ro) {
1039+
if (candiscard && !ro) {
10401040
buf[69] |= ATA_SUPPORT_RZAT | ATA_SUPPORT_DRAT;
10411041
buf[105] = 1;
10421042
buf[169] = ATA_SUPPORT_DSM_TRIM;

devicemodel/include/block_if.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ int blockif_sectsz(struct blockif_ctxt *bc);
5959
void blockif_psectsz(struct blockif_ctxt *bc, int *size, int *off);
6060
int blockif_queuesz(struct blockif_ctxt *bc);
6161
int blockif_is_ro(struct blockif_ctxt *bc);
62-
int blockif_candelete(struct blockif_ctxt *bc);
62+
int blockif_candiscard(struct blockif_ctxt *bc);
6363
int blockif_read(struct blockif_ctxt *bc, struct blockif_req *breq);
6464
int blockif_write(struct blockif_ctxt *bc, struct blockif_req *breq);
6565
int blockif_flush(struct blockif_ctxt *bc, struct blockif_req *breq);
66-
int blockif_delete(struct blockif_ctxt *bc, struct blockif_req *breq);
66+
int blockif_discard(struct blockif_ctxt *bc, struct blockif_req *breq);
6767
int blockif_cancel(struct blockif_ctxt *bc, struct blockif_req *breq);
6868
int blockif_close(struct blockif_ctxt *bc);
6969
uint8_t blockif_get_wce(struct blockif_ctxt *bc);

0 commit comments

Comments
 (0)