All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH v2 23/33] lustre: pfl: Read should not trigger layout write intent
Date: Sun,  6 Jan 2019 17:14:18 -0500	[thread overview]
Message-ID: <1546812868-11794-24-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1546812868-11794-1-git-send-email-jsimmons@infradead.org>

From: Jinshan Xiong <jinshan.xiong@gmail.com>

In lov_io_rw_iter_init(), only write not read operation should
trigger layout write intent.

For append write, it has to make sure all uninited components
are instantiated.

Page mkwrite should also trigger write intent.

Signed-off-by: Jinshan Xiong <jinshan.xiong@gmail.com>
Signed-off-by: Bobi Jam <bobijam@hotmail.com>
WC-bug-id: https://jira.whamcloud.com/browse/LU-9008
Reviewed-on: https://review.whamcloud.com/26499
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/llite/vvp_io.c | 20 ++++++++++++-----
 drivers/staging/lustre/lustre/lov/lov_io.c   | 33 +++++++++++++++++-----------
 2 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c
index c325eba..d9f02ae 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_io.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_io.c
@@ -323,18 +323,26 @@ static void vvp_io_fini(const struct lu_env *env, const struct cl_io_slice *ios)
 	 * RPC.
 	 */
 	if (io->ci_need_write_intent) {
+		loff_t end = OBD_OBJECT_EOF;
 		loff_t start = 0;
-		loff_t end = 0;
-
-		LASSERT(io->ci_type == CIT_WRITE || cl_io_is_trunc(io));
 
 		io->ci_need_write_intent = 0;
 
+		LASSERT(io->ci_type == CIT_WRITE ||
+			cl_io_is_trunc(io) || cl_io_is_mkwrite(io));
+
 		if (io->ci_type == CIT_WRITE) {
-			start = io->u.ci_rw.crw_pos;
-			end = io->u.ci_rw.crw_pos + io->u.ci_rw.crw_count;
-		} else {
+			if (!cl_io_is_append(io)) {
+				start = io->u.ci_rw.crw_pos;
+				end = start + io->u.ci_rw.crw_count;
+			}
+		} else if (cl_io_is_trunc(io)) {
 			end = io->u.ci_setattr.sa_attr.lvb_size;
+		} else { /* mkwrite */
+			pgoff_t index = io->u.ci_fault.ft_index;
+
+			start = cl_offset(io->ci_obj, index);
+			end = cl_offset(io->ci_obj, index + 1);
 		}
 
 		CDEBUG(D_VFSTRACE, DFID" type %d [%llx, %llx)\n",
diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c
index 8a1bb85..0d809b1 100644
--- a/drivers/staging/lustre/lustre/lov/lov_io.c
+++ b/drivers/staging/lustre/lustre/lov/lov_io.c
@@ -378,6 +378,7 @@ static int lov_io_iter_init(const struct lu_env *env,
 {
 	struct lov_io	*lio = cl2lov_io(env, ios);
 	struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
+	struct cl_io *io = ios->cis_io;
 	struct lov_layout_entry *le;
 	struct lov_io_sub    *sub;
 	struct lu_extent ext;
@@ -394,15 +395,28 @@ static int lov_io_iter_init(const struct lu_env *env,
 		u64 start;
 		u64 end;
 
-		CDEBUG(D_VFSTRACE, "component[%d] flags %#x\n",
-		       index, lsm->lsm_entries[index]->lsme_flags);
-		if (!lsm_entry_inited(lsm, index))
-			break;
-
 		index++;
 		if (!lu_extent_is_overlapped(&ext, &le->lle_extent))
 			continue;
 
+		CDEBUG(D_VFSTRACE, "component[%d] flags %#x\n",
+		       index - 1, lsm->lsm_entries[index - 1]->lsme_flags);
+		if (!lsm_entry_inited(lsm, index - 1)) {
+			/* truncate IO will trigger write intent as well, and
+			 * it's handled in lov_io_setattr_iter_init()
+			 */
+			if (io->ci_type == CIT_WRITE || cl_io_is_mkwrite(io)) {
+			    io->ci_need_write_intent = 1;
+				rc = -ENODATA;
+				break;
+			}
+
+			/* Read from uninitialized components should return
+			 * zero filled pages.
+			 */
+			continue;
+		}
+
 		for (stripe = 0; stripe < r0->lo_nr; stripe++) {
 			if (!lov_stripe_intersects(lsm, index - 1, stripe,
 						   &ext, &start, &end))
@@ -498,13 +512,6 @@ static int lov_io_rw_iter_init(const struct lu_env *env,
 	       start, lio->lis_pos, lio->lis_endpos,
 	       lio->lis_io_endpos);
 
-	index = lov_lsm_entry(lsm, lio->lis_endpos - 1);
-	if (index > 0 && !lsm_entry_inited(lsm, index)) {
-		io->ci_need_write_intent = 1;
-		io->ci_result = -ENODATA;
-		return io->ci_result;
-	}
-
 	/*
 	 * XXX The following call should be optimized: we know, that
 	 * [lio->lis_pos, lio->lis_endpos) intersects with exactly one stripe.
@@ -520,7 +527,7 @@ static int lov_io_setattr_iter_init(const struct lu_env *env,
 	struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
 	int index;
 
-	if (cl_io_is_trunc(io) && lio->lis_pos) {
+	if (cl_io_is_trunc(io) && lio->lis_pos > 0) {
 		index = lov_lsm_entry(lsm, lio->lis_pos - 1);
 		if (index > 0 && !lsm_entry_inited(lsm, index)) {
 			io->ci_need_write_intent = 1;
-- 
1.8.3.1

  parent reply	other threads:[~2019-01-06 22:14 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-06 22:13 [lustre-devel] [PATCH v2 00/33] lustre: add PFL support James Simmons
2019-01-06 22:13 ` [lustre-devel] [PATCH v2 01/33] lustre: clio: fix incorrect invariant in cl_io_iter_fini() James Simmons
2019-01-06 22:13 ` [lustre-devel] [PATCH v2 02/33] lustre: pfl: Basic data structures for composite layout James Simmons
2019-01-06 22:13 ` [lustre-devel] [PATCH v2 03/33] lustre: lov: move code for PFL work James Simmons
2019-01-06 22:13 ` [lustre-devel] [PATCH v2 04/33] lustre: lov: merge lov_mds_md_v3 and lov_mds_md_v1 handling James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 05/33] lustre: lov: fold lmm_verify() handling into lmm_unpackmd() James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 06/33] lustre: lov: create struct lov_stripe_md_entry James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 07/33] lustre: lov: add composite layout unpacking James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 08/33] lustre: lov: embedded raid0 in struct lov_layout_composite James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 09/33] lustre: lov: migrate lov raid0 to future PFL component handling James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 10/33] lustre: lov: reduce code indentation James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 11/33] lustre: lov: change lo_entries to array James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 12/33] lustre: lov: move around PFL code and cleanups James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 13/33] lustre: lov: remove lsm_stripe_by_[index|offset]_plain James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 14/33] lustre: lov: add looping lsm_entry_count times James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 15/33] lustre: lov: create lov_comp_* wrappers James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 16/33] lustre: clio: client side implementation for PFL James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 17/33] lustre: clio: getstripe support comp layout James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 18/33] lustre: pfl: enhance PFID EA for PFL James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 19/33] lustre: pfl: dynamic layout modification with write/truncate James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 20/33] lustre: ldlm: Transfer layout only if layout lock is granted James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 21/33] lustre: pfl: calculate PFL file LOVEA correctly James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 22/33] lustre: lov: keep minimum LOVEA size James Simmons
2019-01-06 22:14 ` James Simmons [this message]
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 24/33] lustre: pfl: fix hang with grouplocks James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 25/33] lustre: pfl: fix ost pool op->size handling James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 26/33] lustre: lov: readahead shouldn't exceed component boundary James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 27/33] lustre: uapi: support negative flags James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 28/33] lustre: llite: return v1/v3 layout for legacy app James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 29/33] lustre: llite: restore ll_file_getstripe in ll_lov_setstripe James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 30/33] lustre: lov: do not split IO for single striped file James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 31/33] lustre: lov: call cl_object_attr_get under cl_attr lock James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 32/33] lustre: lov: use stripe_count instead of stripe_nr James Simmons
2019-01-06 22:14 ` [lustre-devel] [PATCH v2 33/33] lustre: update version to 2.9.99 James Simmons
2019-01-08  1:38   ` NeilBrown
2019-01-08  4:26     ` James Simmons
2019-01-08 10:13       ` Andreas Dilger
2019-01-08 21:47         ` James Simmons
2019-01-09  0:15           ` Andreas Dilger
2019-01-09 18:28             ` James Simmons
2019-01-09 23:16               ` Andreas Dilger
2019-01-10  1:36                 ` NeilBrown
2019-01-10  9:10                   ` Andreas Dilger
2019-01-10  1:46           ` NeilBrown
2019-01-10  7:41             ` Andreas Dilger
2019-01-10  0:40         ` NeilBrown
2019-01-10  7:28           ` Andreas Dilger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1546812868-11794-24-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=lustre-devel@lists.lustre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.