struct page *__page;
unsigned char *buffer;
__be16 *guard_start;
- unsigned int bufsize;
int guard_number;
int used_number = 0;
int used;
u32 cksum;
- int rc = 0;
+ unsigned int bufsize = sizeof(cksum);
+ int rc = 0, rc2;
int i = 0;
LASSERT(pg_count > 0);
guard_number, resend, nob, pg_count);
while (nob > 0 && pg_count > 0) {
+ int off = pga[i]->off & ~PAGE_MASK;
unsigned int count = pga[i]->count > nob ? nob : pga[i]->count;
+ int guards_needed = DIV_ROUND_UP(off + count, sector_size) -
+ (off / sector_size);
+
+ if (guards_needed > guard_number - used_number) {
+ cfs_crypto_hash_update_page(req, __page, 0,
+ used_number * sizeof(*guard_start));
+ used_number = 0;
+ }
/* corrupt the data before we compute the checksum, to
* simulate an OST->client data error */
if (unlikely(i == 0 && opc == OST_READ &&
OBD_FAIL_CHECK(OBD_FAIL_OSC_CHECKSUM_RECEIVE))) {
unsigned char *ptr = kmap(pga[i]->pg);
- int off = pga[i]->off & ~PAGE_MASK;
memcpy(ptr + off, "bad1", min_t(typeof(nob), 4, nob));
kunmap(pga[i]->pg);
break;
used_number += used;
- if (used_number == guard_number) {
- cfs_crypto_hash_update_page(req, __page, 0,
- used_number * sizeof(*guard_start));
- used_number = 0;
- }
-
nob -= pga[i]->count;
pg_count--;
i++;
}
kunmap(__page);
if (rc)
- GOTO(out, rc);
+ GOTO(out_hash, rc);
if (used_number != 0)
cfs_crypto_hash_update_page(req, __page, 0,
used_number * sizeof(*guard_start));
- bufsize = sizeof(cksum);
- cfs_crypto_hash_final(req, (unsigned char *)&cksum, &bufsize);
-
- /* For sending we only compute the wrong checksum instead
- * of corrupting the data so it is still correct on a redo */
- if (opc == OST_WRITE && OBD_FAIL_CHECK(OBD_FAIL_OSC_CHECKSUM_SEND))
- cksum++;
+out_hash:
+ rc2 = cfs_crypto_hash_final(req, (unsigned char *)&cksum, &bufsize);
+ if (!rc)
+ rc = rc2;
+ if (rc == 0) {
+ /* For sending we only compute the wrong checksum instead
+ * of corrupting the data so it is still correct on a redo */
+ if (opc == OST_WRITE &&
+ OBD_FAIL_CHECK(OBD_FAIL_OSC_CHECKSUM_SEND))
+ cksum++;
- *check_sum = cksum;
+ *check_sum = cksum;
+ }
out:
__free_page(__page);
return rc;
CDEBUG(D_PAGE | D_HA, "GRD tags per page = %u\n", guard_number);
for (i = 0; i < npages; i++) {
bool use_t10_grd;
+ int off = local_nb[i].lnb_page_offset & ~PAGE_MASK;
+ int len = local_nb[i].lnb_len;
+ int guards_needed = DIV_ROUND_UP(off + len, sector_size) -
+ (off / sector_size);
+
+ if (guards_needed > guard_number - used_number) {
+ cfs_crypto_hash_update_page(req, __page, 0,
+ used_number * sizeof(*guard_start));
+ used_number = 0;
+ }
/* corrupt the data before we compute the checksum, to
* simulate a client->OST data error */
if (i == 0 && opc == OST_WRITE &&
OBD_FAIL_CHECK(OBD_FAIL_OST_CHECKSUM_RECEIVE)) {
- int off = local_nb[i].lnb_page_offset & ~PAGE_MASK;
- int len = local_nb[i].lnb_len;
struct page *np = tgt_page_to_corrupt;
if (np) {
local_nb[i].lnb_len == PAGE_SIZE &&
local_nb[i].lnb_guard_disk;
if (use_t10_grd) {
- used = DIV_ROUND_UP(local_nb[i].lnb_len, sector_size);
+ used = guards_needed;
if (used > (guard_number - used_number)) {
rc = -E2BIG;
CDEBUG(D_PAGE | D_HA,
}
used_number += used;
- if (used_number == guard_number) {
- cfs_crypto_hash_update_page(req, __page, 0,
- used_number * sizeof(*guard_start));
- used_number = 0;
- }
/* corrupt the data after we compute the checksum, to
* simulate an OST->client data error */
if (unlikely(i == 0 && opc == OST_READ &&
OBD_FAIL_CHECK(OBD_FAIL_OST_CHECKSUM_SEND))) {
- int off = local_nb[i].lnb_page_offset & ~PAGE_MASK;
- int len = local_nb[i].lnb_len;
struct page *np = tgt_page_to_corrupt;
if (np) {