From patchwork Thu Feb 27 21:16:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11410903 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 424F41580 for ; Thu, 27 Feb 2020 21:50:25 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2A18B24690 for ; Thu, 27 Feb 2020 21:50:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A18B24690 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 804F034A9AA; Thu, 27 Feb 2020 13:41:34 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 185A2348901 for ; Thu, 27 Feb 2020 13:21:06 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 920FC91B4; Thu, 27 Feb 2020 16:18:19 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 90D0346C; Thu, 27 Feb 2020 16:18:19 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:16:46 -0500 Message-Id: <1582838290-17243-539-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 538/622] lustre: llite: file write pos mimatch 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: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Bobi Jam In vvp_io_write_start(), after data were successfully written, but for some reason (e.g. out of quota), the data does not or got partially commited, so that the file's write position (kiocb->ki_pos) would be pushed forward falsely, and in the next iteration of write loop, it fails the assertion ASSERTION( io->u.ci_rw.rw_iocb.ki_pos == range->cir_pos ) This patch corrects ki_pos if this scenario happens. WC-bug-id: https://jira.whamcloud.com/browse/LU-12503 Lustre-commit: 1d2aa1513dc4 ("LU-12503 llite: file write pos mimatch") Signed-off-by: Bobi Jam Reviewed-on: https://review.whamcloud.com/36021 Reviewed-by: Wang Shilong Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/vvp_io.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/lustre/llite/vvp_io.c b/fs/lustre/llite/vvp_io.c index aa8f2e1..b3f628c 100644 --- a/fs/lustre/llite/vvp_io.c +++ b/fs/lustre/llite/vvp_io.c @@ -1068,9 +1068,12 @@ static int vvp_io_write_start(const struct lu_env *env, struct cl_object *obj = io->ci_obj; struct inode *inode = vvp_object_inode(obj); struct ll_inode_info *lli = ll_i2info(inode); + struct file *file = vio->vui_fd->fd_file; bool lock_inode = !inode_is_locked(inode) && !IS_NOSEC(inode); loff_t pos = io->u.ci_wr.wr.crw_pos; size_t cnt = io->u.ci_wr.wr.crw_count; + size_t nob = io->ci_nob; + size_t written = 0; ssize_t result = 0; down_read(&lli->lli_trunc_sem); @@ -1135,6 +1138,7 @@ static int vvp_io_write_start(const struct lu_env *env, if (unlikely(lock_inode)) inode_unlock(inode); + written = result; if (result > 0 || result == -EIOCBQUEUED) result = generic_write_sync(vio->vui_iocb, result); } @@ -1149,6 +1153,15 @@ static int vvp_io_write_start(const struct lu_env *env, io->ci_nob, result); } } + if (vio->vui_iocb->ki_pos != (pos + io->ci_nob - nob)) { + CDEBUG(D_VFSTRACE, + "%s: write position mismatch: ki_pos %lld vs. pos %lld, written %ld, commit %ld rc %ld\n", + file_dentry(file)->d_name.name, + vio->vui_iocb->ki_pos, pos + io->ci_nob - nob, + written, io->ci_nob - nob, result); + /* rewind ki_pos to where it has successfully committed */ + vio->vui_iocb->ki_pos = pos + io->ci_nob - nob; + } if (result > 0) { set_bit(LLIF_DATA_MODIFIED, &(ll_i2info(inode))->lli_flags);