From patchwork Sun Jan 6 22:14:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10749713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85CCE91E for ; Sun, 6 Jan 2019 22:15:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 771FC2895F for ; Sun, 6 Jan 2019 22:15:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AFD828968; Sun, 6 Jan 2019 22:15:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 054AA2895F for ; Sun, 6 Jan 2019 22:15:14 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id D0BA9681ED2; Sun, 6 Jan 2019 14:14:52 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id D091C21F90D for ; Sun, 6 Jan 2019 14:14:39 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id CBD32100516A; Sun, 6 Jan 2019 17:14:30 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id CA5F61E3; Sun, 6 Jan 2019 17:14:30 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Sun, 6 Jan 2019 17:14:18 -0500 Message-Id: <1546812868-11794-24-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1546812868-11794-1-git-send-email-jsimmons@infradead.org> References: <1546812868-11794-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH v2 23/33] lustre: pfl: Read should not trigger layout write intent X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bobi Jam , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jinshan Xiong 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 Signed-off-by: Bobi Jam WC-bug-id: https://jira.whamcloud.com/browse/LU-9008 Reviewed-on: https://review.whamcloud.com/26499 Reviewed-by: Andreas Dilger Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- 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;