From ea9e398471b5d271d81d6d45fc3c3923a5825415 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Fri, 3 Nov 2023 16:29:51 -0400 Subject: [PATCH] EX-7601 ofd: distinguish nr_write and nr_read We will have two counts of pages in lnbs, distinguish between them. Not actually used yet - will be calculated when the read lnb mapping is created. Signed-off-by: Patrick Farrell Change-Id: I709b8fd299163d348a196184152bb0294fcb650b Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52985 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Artem Blagodarenko --- lustre/ofd/ofd_io.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index f9ab71b..43f91db 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -748,7 +748,7 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp, struct ofd_device *ofd, const struct lu_fid *fid, struct lu_attr *la, struct obdo *oa, int objcount, struct obd_ioobj *obj, - struct niobuf_remote *rnb, int *nr_local, + struct niobuf_remote *rnb, int *nr_write, struct niobuf_local *write_lnb, struct niobuf_local *read_lnb, enum ll_compr_type type, int lvl, int chunk_bits) @@ -759,9 +759,11 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp, int chunk_size = chunk_bits ? 1 << chunk_bits : 0; enum dt_bufs_type dbt = DT_BUFS_TYPE_WRITE; bool compr_unaligned_write = false; - int maxlnb = *nr_local; __u64 prev_buf_end = 0; + int maxlnb = *nr_write; int tot_bytes = 0; + /* not implemented yet - will be determined later */ + int nr_read; __u64 begin; int rc = 0; __u64 end; @@ -852,7 +854,7 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp, end = 0; /* parse remote buffers to local buffers and prepare the latter */ - for (*nr_local = 0, i = 0, j = 0; i < obj->ioo_bufcnt; i++) { + for (*nr_write = 0, i = 0, j = 0; i < obj->ioo_bufcnt; i++) { __u64 orig_start; __u64 buf_start; __u64 orig_end; @@ -942,12 +944,12 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp, write_lnb[j+k].lnb_rc = -ENOSPC; } j += rc; - *nr_local += rc; + *nr_write += rc; maxlnb -= rc; LASSERT(j <= PTLRPC_MAX_BRW_PAGES); tot_bytes += rnb[i].rnb_len; } - LASSERT(*nr_local > 0 && *nr_local <= PTLRPC_MAX_BRW_PAGES); + LASSERT(*nr_write > 0 && *nr_write <= PTLRPC_MAX_BRW_PAGES); ofd_read_lock(env, fo); if (!ofd_object_exists(fo)) { @@ -971,13 +973,14 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp, if (compr_unaligned_write) { read_lnb = write_lnb; + nr_read = *nr_write; rc = dt_read_prep(env, ofd_object_child(fo), read_lnb, - *nr_local, true); + nr_read, true); if (unlikely(rc != 0)) GOTO(err, rc); rc = ofd_decompress_read(env, exp, oa, rnb, read_lnb, obj, - *nr_local, type, lvl, chunk_bits, + nr_read, type, lvl, chunk_bits, true); if (unlikely(rc != 0)) GOTO(err, rc); @@ -985,13 +988,13 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp, * write code expects rc to be zero, so we clear rc here except * on error */ - for (i = 0; i < *nr_local; i++) { + for (i = 0; i < nr_read; i++) { if (read_lnb[i].lnb_rc > 0) read_lnb[i].lnb_rc = 0; } } - rc = dt_write_prep(env, ofd_object_child(fo), write_lnb, *nr_local); + rc = dt_write_prep(env, ofd_object_child(fo), write_lnb, *nr_write); if (unlikely(rc != 0)) GOTO(err, rc); @@ -1033,7 +1036,7 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp, err: ofd_read_unlock(env, fo); err_nolock: - dt_bufs_put(env, ofd_object_child(fo), write_lnb, *nr_local); + dt_bufs_put(env, ofd_object_child(fo), write_lnb, *nr_write); ofd_object_put(env, fo); /* tgt_grant_prepare_write() was called, so we must commit */ tgt_grant_commit(exp, oa->o_grant_used, rc); -- 1.8.3.1