From patchwork Thu Feb 27 21:13:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11410187 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 D12D0138D for ; Thu, 27 Feb 2020 21:32:18 +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 B984524677 for ; Thu, 27 Feb 2020 21:32:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B984524677 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 4A832349100; Thu, 27 Feb 2020 13:27:23 -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 3BEC521FEFD for ; Thu, 27 Feb 2020 13:19:55 -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 0B84C8A50; Thu, 27 Feb 2020 16:18:17 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 09AB346F; Thu, 27 Feb 2020 16:18:17 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:13:03 -0500 Message-Id: <1582838290-17243-316-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 315/622] lustre: llite: check correct size in ll_dom_finish_open() 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: Mikhail Pershin , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mikhail Pershin The check in ll_dom_finish_open() for data end shouldn't use i_size for comparision because it may be not updated yet with just returned data from server. Use size value in mdt_body from reply for that check. WC-bug-id: https://jira.whamcloud.com/browse/LU-12014 Lustre-commit: 7b9fd576f7de ("LU-12014 llite: check correct size in ll_dom_finish_open()") Signed-off-by: Mikhail Pershin Reviewed-on: https://review.whamcloud.com/33895 Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- fs/lustre/llite/file.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c index 50220eb..88d5c2d 100644 --- a/fs/lustre/llite/file.c +++ b/fs/lustre/llite/file.c @@ -418,6 +418,7 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req, struct address_space *mapping = inode->i_mapping; struct page *vmpage; struct niobuf_remote *rnb; + struct mdt_body *body; char *data; unsigned long index, start; struct niobuf_local lnb; @@ -441,18 +442,19 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req, if (rnb->rnb_offset % PAGE_SIZE) return; - /* Server returns whole file or just file tail if it fills in - * reply buffer, in both cases total size should be inode size. + /* Server returns whole file or just file tail if it fills in reply + * buffer, in both cases total size should be equal to the file size. */ - if (rnb->rnb_offset + rnb->rnb_len < i_size_read(inode)) { - CERROR("%s: server returns off/len %llu/%u < i_size %llu\n", + body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); + if (rnb->rnb_offset + rnb->rnb_len != body->mbo_dom_size) { + CERROR("%s: server returns off/len %llu/%u but size %llu\n", ll_i2sbi(inode)->ll_fsname, rnb->rnb_offset, - rnb->rnb_len, i_size_read(inode)); + rnb->rnb_len, body->mbo_dom_size); return; } - CDEBUG(D_INFO, "Get data along with open at %llu len %i, i_size %llu\n", - rnb->rnb_offset, rnb->rnb_len, i_size_read(inode)); + CDEBUG(D_INFO, "Get data along with open at %llu len %i, size %llu\n", + rnb->rnb_offset, rnb->rnb_len, body->mbo_dom_size); data = (char *)rnb + sizeof(*rnb);