struct ptlrpc_request *req = tgt_ses_req(tsi);
struct tgt_thread_big_cache *tbc = req->rq_svc_thread->t_data;
struct obd_export *exp = req->rq_export;
+ struct niobuf_remote chunk_lock_rnb;
struct ptlrpc_bulk_desc *desc = NULL;
struct lustre_handle lockh = {0};
struct niobuf_remote *remote_nb;
struct ost_layout_compr *olc;
const char *obd_name = exp->exp_obd->obd_name;
enum cksum_types cksum_type = OBD_CKSUM_CRC32;
+ bool compr_rounded_write_lock = false;
/* '1' for consistency with code that checks !mpflag to restore */
unsigned int mpflags = 1;
enum ll_compr_type type;
io_start, io_end, chunk_start, chunk_end);
/* the start or end of this IO is unaligned */
- if (io_start != chunk_start || io_end != chunk_end)
- CDEBUG(D_SEC, "unaligned write\n");
+ if (io_start != chunk_start || io_end != chunk_end) {
+ chunk_lock_rnb.rnb_offset = chunk_start;
+ chunk_lock_rnb.rnb_len = chunk_end - chunk_start;
+ chunk_lock_rnb.rnb_flags = remote_nb[0].rnb_flags;
+ compr_rounded_write_lock = true;
+ }
}
- rc = tgt_brw_lock(tsi->tsi_env, exp, &tsi->tsi_resid, remote_nb, &lockh,
- LCK_PW, niocount);
+ rc = tgt_brw_lock(tsi->tsi_env, exp, &tsi->tsi_resid,
+ compr_rounded_write_lock ? &chunk_lock_rnb : remote_nb,
+ &lockh, LCK_PW,
+ compr_rounded_write_lock ? 1 : niocount);
if (rc != 0)
GOTO(out, rc);
+ /* NB/FIXME/to-be-removed: we can't do the 'skip unaligned io and
+ * return EINVAL trick like we do for reads, because unaligned writes
+ * at EOF are supported
+ */
+
/*
* If getting the lock took more time than
* client was willing to wait, drop it. b=11330
ptlrpc_lprocfs_brw(req, nob);
}
out_lock:
- tgt_brw_unlock(exp, ioo, remote_nb, &lockh, LCK_PW);
+ tgt_brw_unlock(exp, ioo,
+ compr_rounded_write_lock ? &chunk_lock_rnb : remote_nb,
+ &lockh, LCK_PW);
if (desc)
ptlrpc_free_bulk(desc);
out: