From patchwork Wed Feb 19 05:04:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 11390355 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 B65B192A for ; Wed, 19 Feb 2020 05:04:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 946A024658 for ; Wed, 19 Feb 2020 05:04:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MsfkXTf1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725306AbgBSFEe (ORCPT ); Wed, 19 Feb 2020 00:04:34 -0500 Received: from mail-io1-f43.google.com ([209.85.166.43]:37597 "EHLO mail-io1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbgBSFEd (ORCPT ); Wed, 19 Feb 2020 00:04:33 -0500 Received: by mail-io1-f43.google.com with SMTP id k24so12530295ioc.4; Tue, 18 Feb 2020 21:04:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=T+zw2Qm3/xbBkKSwmBe22NRY31UuKAJITVOOzl+77eA=; b=MsfkXTf19mx8D7AP3ycC8KURgWYqrSYRSa5B9TsaVelWDgmBZ6PfipEHS5HG5/eSCV SZzTAq2baj0GaDQxM8mV8YKl6TxsaxccUCjiFkQWdO3e6+ZjoNkldMRKeJ5p/1LtHwDU KAEZVoW9I26Lf0cOree+jGhIr4D4eoCp+uFIcoU5s9PwZC70GeyqxVUYdU5REGhcOV+b PxmjrkoilPk2JZ9rbmJAt4NHmctPsaSIjSxZAHJQl15DbObKInX/aFMW7pQT3saMLXwG aw8Qibj9TIkY31Uojjx0bRNu307nIxpaa31RPkL8K8dVehleMxNFln9dSMWbkOg5Rjry q0ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=T+zw2Qm3/xbBkKSwmBe22NRY31UuKAJITVOOzl+77eA=; b=XQMrym71DxCaOGiiRTNPBwbhFCN141EekHI4S8TKYlp+RLXED6CLeIKJx+IIYKT6eV y8GOdchW1HG/SznJLjndj85c0/duwW5L5zbdCQ1aqCXX1u7UjoARrZKKPxXoM2RRq/LA Kwn5Fda5HPz5bhsFl2H5VSOYWXlyKZXWWVu3/qHB/vvWoapVyMvu7TedI4QkHoDW8cLQ X5clIbkpZhkbzD7Q/EwBF3RXVP4nVSQiH1hwIiZP4zX4IoY2kjdWqsZjhp7mMGMaFR2Q tBaeNLn8Of+n5kR5/gbLNB7SmAha4ezum09k3VFdOOgmCqUFdUQ0VF1z2BCYfvnfmO4w cAyw== X-Gm-Message-State: APjAAAWPPdX/It3rAW0eFZh4CRCYIZrNWp7UFKoS+zw5rI/WtrBj2BTa 7R2CRqlyNKEiOPXw93oGajZRyz7ZsgIeQkjaICIQFM0h X-Google-Smtp-Source: APXvYqybgjrdSWOrhAPtC9bWGiJygbOt/r9tcYOoSyyg1GTQiwGuhSi70XPhYPOhscPlWoXflly7DhKiJvvJFC9UYg8= X-Received: by 2002:a02:2a06:: with SMTP id w6mr20191742jaw.63.1582088672744; Tue, 18 Feb 2020 21:04:32 -0800 (PST) MIME-Version: 1.0 From: Steve French Date: Tue, 18 Feb 2020 23:04:21 -0600 Message-ID: Subject: [CIFS][PATCH] Honor the AT_SYNC_TYPE flags To: CIFS Cc: linux-fsdevel Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org cifs.ko should not ignore the SYNC flags in getattr Check the AT_STATX_FORCE_SYNC flag and force an attribute revalidation if requested by the caller, and if the caller specificies AT_STATX_DONT_SYNC only revalidate cached attributes if required. In addition do not flush writes in getattr (which can be expensive) if size or timestamps not requested by the caller. Reviewed-by: Aurelien Aptel From 29361590ed10fe5db2b02574b19d3ed8afec5bf4 Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 18 Feb 2020 18:07:57 -0600 Subject: [PATCH] cifs: do not ignore the SYNC flags in getattr Check the AT_STATX_FORCE_SYNC flag and force an attribute revalidation if requested by the caller, and if the caller specificies AT_STATX_DONT_SYNC only revalidate cached attributes if required. In addition do not flush writes in getattr (which can be expensive) if size or timestamps not requested by the caller. Signed-off-by: Steve French --- fs/cifs/inode.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 1212ace05258..4fed7a9117c6 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -2148,8 +2148,9 @@ int cifs_getattr(const struct path *path, struct kstat *stat, * We need to be sure that all dirty pages are written and the server * has actual ctime, mtime and file length. */ - if (!CIFS_CACHE_READ(CIFS_I(inode)) && inode->i_mapping && - inode->i_mapping->nrpages != 0) { + if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_SIZE)) && + !CIFS_CACHE_READ(CIFS_I(inode)) && + inode->i_mapping && inode->i_mapping->nrpages != 0) { rc = filemap_fdatawait(inode->i_mapping); if (rc) { mapping_set_error(inode->i_mapping, rc); @@ -2157,9 +2158,20 @@ int cifs_getattr(const struct path *path, struct kstat *stat, } } - rc = cifs_revalidate_dentry_attr(dentry); - if (rc) - return rc; + if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_FORCE_SYNC) + CIFS_I(inode)->time = 0; /* force revalidate */ + + /* + * If the caller doesn't require syncing, only sync if + * necessary (e.g. due to earlier truncate or setattr + * invalidating the cached metadata) + */ + if (((flags & AT_STATX_SYNC_TYPE) != AT_STATX_DONT_SYNC) || + (CIFS_I(inode)->time == 0)) { + rc = cifs_revalidate_dentry_attr(dentry); + if (rc) + return rc; + } generic_fillattr(inode, stat); stat->blksize = cifs_sb->bsize; -- 2.20.1