Skip to content

Commit 6109e6f

Browse files
committed
libnvme/cmds: change copy desc format elbatm and elbat to big-endian
Since the format elbt values are set as big-endian then follow it. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 4fe3b3e commit 6109e6f

3 files changed

Lines changed: 27 additions & 19 deletions

File tree

libnvme/src/nvme/cmds.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5272,8 +5272,10 @@ nvme_init_copy_range_f0(struct nvme_copy_range_f0 *copy, __u16 *nlbs,
52725272
copy[i].slba = htole64(slbas[i]);
52735273
nvme_init_copy_range_elbt(copy[i].elbt, (__u8 *)&elbts[i],
52745274
sizeof(elbts[i]));
5275-
copy[i].elbatm = htole16(elbatms[i]);
5276-
copy[i].elbat = htole16(elbats[i]);
5275+
nvme_init_copy_range_elbt(copy[i].elbatm, (__u8 *)&elbatms[i],
5276+
sizeof(copy[i].elbatm));
5277+
nvme_init_copy_range_elbt(copy[i].elbat, (__u8 *)&elbats[i],
5278+
sizeof(copy[i].elbat));
52775279
}
52785280
}
52795281

@@ -5299,10 +5301,12 @@ nvme_init_copy_range_f1(struct nvme_copy_range_f1 *copy, __u16 *nlbs,
52995301
for (i = 0; i < nr; i++) {
53005302
copy[i].nlb = htole16(nlbs[i]);
53015303
copy[i].slba = htole64(slbas[i]);
5302-
copy[i].elbatm = htole16(elbatms[i]);
5303-
copy[i].elbat = htole16(elbats[i]);
53045304
nvme_init_copy_range_elbt(&copy[i].elbt[2], (__u8 *)&eilbrts[i],
53055305
sizeof(eilbrts[i]));
5306+
nvme_init_copy_range_elbt(copy[i].elbatm, (__u8 *)&elbatms[i],
5307+
sizeof(copy[i].elbatm));
5308+
nvme_init_copy_range_elbt(copy[i].elbat, (__u8 *)&elbats[i],
5309+
sizeof(copy[i].elbat));
53065310
}
53075311
}
53085312

@@ -5333,8 +5337,10 @@ nvme_init_copy_range_f2(struct nvme_copy_range_f2 *copy,
53335337
copy[i].sopt = htole16(sopts[i]);
53345338
nvme_init_copy_range_elbt(copy[i].elbt, (__u8 *)&elbts[i],
53355339
sizeof(elbts[i]));
5336-
copy[i].elbatm = htole16(elbatms[i]);
5337-
copy[i].elbat = htole16(elbats[i]);
5340+
nvme_init_copy_range_elbt(copy[i].elbatm, (__u8 *)&elbatms[i],
5341+
sizeof(copy[i].elbatm));
5342+
nvme_init_copy_range_elbt(copy[i].elbat, (__u8 *)&elbats[i],
5343+
sizeof(copy[i].elbat));
53385344
}
53395345
}
53405346

@@ -5365,10 +5371,12 @@ nvme_init_copy_range_f3(struct nvme_copy_range_f3 *copy, __u32 *snsids,
53655371
copy[i].nlb = htole16(nlbs[i]);
53665372
copy[i].slba = htole64(slbas[i]);
53675373
copy[i].sopt = htole16(sopts[i]);
5368-
copy[i].elbatm = htole16(elbatms[i]);
5369-
copy[i].elbat = htole16(elbats[i]);
53705374
nvme_init_copy_range_elbt(&copy[i].elbt[2], (__u8 *)&eilbrts[i],
53715375
sizeof(eilbrts[i]));
5376+
nvme_init_copy_range_elbt(copy[i].elbatm, (__u8 *)&elbatms[i],
5377+
sizeof(copy[i].elbatm));
5378+
nvme_init_copy_range_elbt(copy[i].elbat, (__u8 *)&elbats[i],
5379+
sizeof(copy[i].elbat));
53725380
}
53735381
}
53745382

libnvme/src/nvme/types.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6458,8 +6458,8 @@ struct nvme_copy_range_f0 {
64586458
__le16 cev;
64596459
__u8 rsvd22[2];
64606460
__u8 elbt[4];
6461-
__le16 elbat;
6462-
__le16 elbatm;
6461+
__u8 elbat[2];
6462+
__u8 elbatm[2];
64636463
};
64646464

64656465
/**
@@ -6485,8 +6485,8 @@ struct nvme_copy_range_f1 {
64856485
__le16 cev;
64866486
__u8 rsvd22[4];
64876487
__u8 elbt[10];
6488-
__le16 elbat;
6489-
__le16 elbatm;
6488+
__u8 elbat[2];
6489+
__u8 elbatm[2];
64906490
};
64916491

64926492
/**
@@ -6522,8 +6522,8 @@ struct nvme_copy_range_f2 {
65226522
__le16 cev;
65236523
__le16 sopt;
65246524
__u8 elbt[4];
6525-
__le16 elbat;
6526-
__le16 elbatm;
6525+
__u8 elbat[2];
6526+
__u8 elbatm[2];
65276527
};
65286528

65296529
/**
@@ -6553,8 +6553,8 @@ struct nvme_copy_range_f3 {
65536553
__le16 sopt;
65546554
__u8 rsvd24[2];
65556555
__u8 elbt[10];
6556-
__le16 elbat;
6557-
__le16 elbatm;
6556+
__u8 elbat[2];
6557+
__u8 elbatm[2];
65586558
};
65596559

65606560
/**

libnvme/test/ioctl/misc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -995,11 +995,11 @@ static void test_copy(void)
995995
__u32 elbats[TEST_COPY_NR] = { 0x111, 0x222, 0x333 };
996996
__u8 expected_data[sizeof(struct nvme_copy_range_f0) * TEST_COPY_NR] = {
997997
0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0, 0, 0, 0,
998-
0xa, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0x11, 1, 0xff, 1,
998+
0xa, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 1, 0x11, 1, 0xff,
999999
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x20, 0, 0, 0, 0,
1000-
0xb, 0, 0, 0, 0, 0, 0, 0, 0x20, 0, 0, 0, 0x22, 2, 0xff, 3,
1000+
0xb, 0, 0, 0, 0, 0, 0, 0, 0x20, 0, 0, 0, 2, 0x22, 3, 0xff,
10011001
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0x30, 0, 0,
1002-
0xc, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0, 0, 0x33, 3, 0xff, 3
1002+
0xc, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0, 0, 3, 0x33, 3, 0xff
10031003
};
10041004

10051005
_cleanup_free_ struct nvme_copy_range_f0 *copy = NULL;

0 commit comments

Comments
 (0)