const char *obd_name = exp->exp_obd->obd_name;
enum cksum_types cksum_type = OBD_CKSUM_CRC32;
bool compr_rounded_write_lock = false;
+ enum ll_compr_type compr_type;
/* '1' for consistency with code that checks !mpflag to restore */
unsigned int mpflags = 1;
- enum ll_compr_type type;
bool wait_sync = false;
bool no_reply = false;
+ int npages_remote = 0;
int chunk_size = 0;
+ int npages_local;
ktime_t kstart;
int objcount;
int niocount;
int nob = 0;
- int npages;
int rc = 0;
__u32 *rcs;
bool mmap;
local_nb = tbc->tbc_lnb;
olc = &body->oa.o_layout_compr;
- type = olc->ol_compr_type;
- if (type != LL_COMPR_TYPE_NONE) {
+ compr_type = olc->ol_compr_type;
+ if (compr_type != LL_COMPR_TYPE_NONE) {
int nrbufs = ioo->ioo_bufcnt;
unsigned int chunk_log_bits;
__u64 chunk_start;
GOTO(out_lock, rc = -ENOMEM);
repbody->oa = body->oa;
- npages = PTLRPC_MAX_BRW_PAGES;
+ npages_local = PTLRPC_MAX_BRW_PAGES;
+ for (i = 0; i < niocount; i++)
+ npages_remote += range_to_page_count(remote_nb[i].rnb_offset,
+ remote_nb[i].rnb_len);
kstart = ktime_get();
rc = obd_preprw(tsi->tsi_env, OBD_BRW_WRITE, exp, &repbody->oa,
- objcount, ioo, remote_nb, &npages, local_nb,
+ objcount, ioo, remote_nb, &npages_local, local_nb,
chunk_size);
if (rc < 0)
GOTO(out_lock, rc);
+
+ if (compr_type == LL_COMPR_TYPE_NONE) {
+ /* if there's no compression, the local page count should be
+ * identical to that requested by the client
+ */
+ LASSERT(npages_local == npages_remote);
+ }
+
if (body->oa.o_valid & OBD_MD_FLFLAGS &&
body->oa.o_flags & OBD_FL_SHORT_IO) {
unsigned int short_io_size;
" size = %d\n", short_io_size);
/* Copy short io buf to pages */
- rc = tgt_shortio2pages(local_nb, npages, short_io_buf,
+ rc = tgt_shortio2pages(local_nb, npages_remote, short_io_buf,
short_io_size);
desc = NULL;
} else {
- desc = ptlrpc_prep_bulk_exp(req, npages, ioobj_max_brw_get(ioo),
+ desc = ptlrpc_prep_bulk_exp(req, npages_remote,
+ ioobj_max_brw_get(ioo),
PTLRPC_BULK_GET_SINK,
OST_BULK_PORTAL,
&ptlrpc_bulk_kiov_nopin_ops);
GOTO(skip_transfer, rc = -ENOMEM);
/* NB Having prepped, we must commit... */
- for (i = 0; i < npages; i++) {
+ for (i = 0; i < npages_remote; i++) {
CDEBUG(D_SEC, "adding frag, page %d, offset %lu, len %d\n",
i, local_nb[i].lnb_page_offset & ~PAGE_MASK,
local_nb[i].lnb_len);
cksum_type);
rc = tgt_checksum_niobuf_rw(tsi->tsi_tgt, cksum_type,
- local_nb, npages, OST_WRITE,
+ local_nb, npages_remote, OST_WRITE,
&repbody->oa.o_cksum, false);
if (rc < 0)
GOTO(out_commitrw, rc);
mmap = (body->oa.o_valid & OBD_MD_FLFLAGS &&
body->oa.o_flags & OBD_FL_MMAP);
- tgt_warn_on_cksum(req, desc, local_nb, npages,
+ tgt_warn_on_cksum(req, desc, local_nb, npages_remote,
body->oa.o_cksum,
repbody->oa.o_cksum, mmap);
cksum_counter = 0;
/* Must commit after prep above in all cases */
rc = obd_commitrw(tsi->tsi_env, OBD_BRW_WRITE, exp, &repbody->oa,
- objcount, ioo, remote_nb, npages, local_nb, rc, nob,
- kstart);
+ objcount, ioo, remote_nb, npages_local, local_nb,
+ rc, nob, kstart);
if (rc == -ENOTCONN)
/* quota acquire process has been given up because
* either the client has been evicted or the client
rcs[i] = 0;
do {
- LASSERT(j < npages);
+ LASSERT(j < npages_remote);
if (local_nb[j].lnb_rc < 0)
rcs[i] = local_nb[j].lnb_rc;
len -= local_nb[j].lnb_len;
} while (len > 0);
LASSERT(len == 0);
}
- LASSERT(j == npages);
+ LASSERT(j == npages_remote);
ptlrpc_lprocfs_brw(req, nob);
}
out_lock: