From patchwork Wed May 25 22:34:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12861776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67625C433FE for ; Wed, 25 May 2022 22:34:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 976178D000D; Wed, 25 May 2022 18:34:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9241A8D0001; Wed, 25 May 2022 18:34:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74CF88D000D; Wed, 25 May 2022 18:34:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5EFE68D0001 for ; Wed, 25 May 2022 18:34:55 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 28BE060193 for ; Wed, 25 May 2022 22:34:55 +0000 (UTC) X-FDA: 79505721750.01.6479E17 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf28.hostedemail.com (Postfix) with ESMTP id BD784C0025 for ; Wed, 25 May 2022 22:34:21 +0000 (UTC) Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24PGtZxu017198 for ; Wed, 25 May 2022 15:34:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=BE5eLO5Z7AZICxMCDTAcJeiKudbeydb7d4UMFp50BLA=; b=I2su/43ctP7xinp5heyI+ieMK5r2Aa9OkURbSwM+dAE8k7Mb3x6fOD61S0gdvEcdg/Bh MuF36VB4cZWS2A+fvxnRbpgPddhdop/wFcEFMIt1mH0n/6BSZptJMARdlk4U5eGA1Fgz xGCt07tFT5Su2+LeYS4VgZF5YfYArBg9UWk= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g93vs9eb1-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 25 May 2022 15:34:53 -0700 Received: from twshared4937.07.ash9.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 25 May 2022 15:34:52 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 2AD47F9E1B6C; Wed, 25 May 2022 15:34:35 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , , Subject: [PATCH v5 10/16] fs: Optimization for concurrent file time updates. Date: Wed, 25 May 2022 15:34:26 -0700 Message-ID: <20220525223432.205676-11-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220525223432.205676-1-shr@fb.com> References: <20220525223432.205676-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: qp80cOHAU429auNQcpnsHouklnczUA86 X-Proofpoint-GUID: qp80cOHAU429auNQcpnsHouklnczUA86 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-25_06,2022-05-25_02,2022-02-23_01 X-Rspam-User: X-Rspamd-Queue-Id: BD784C0025 X-Stat-Signature: rtcjg69ykogwx9r5tstkg75e83rtbz8p Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b="I2su/43c"; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf28.hostedemail.com: domain of "prvs=61440c7716=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=61440c7716=shr@fb.com" X-Rspamd-Server: rspam04 X-HE-Tag: 1653518061-596109 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This introduces the S_PENDING_TIME flag. If an async buffered write needs to update the time, it cannot be processed in the fast path of io-uring. When a time update is pending this flag is set for async buffered writes. Other concurrent async buffered writes for the same file do not need to wait while this time update is pending. This reduces the number of async buffered writes that need to get punted to the io-workers in io-uring. Signed-off-by: Stefan Roesch --- fs/inode.c | 11 +++++++++-- include/linux/fs.h | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 4503bed063e7..7185d860d423 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2150,10 +2150,17 @@ static int file_modified_flags(struct file *file, int flags) ret = inode_needs_update_time(inode, &now); if (ret <= 0) return ret; - if (flags & IOCB_NOWAIT) + if (flags & IOCB_NOWAIT) { + if (IS_PENDING_TIME(inode)) + return 0; + + inode_set_flags(inode, S_PENDING_TIME, S_PENDING_TIME); return -EAGAIN; + } - return __file_update_time(file, &now, ret); + ret = __file_update_time(file, &now, ret); + inode_set_flags(inode, 0, S_PENDING_TIME); + return ret; } /** diff --git a/include/linux/fs.h b/include/linux/fs.h index 2d9b3afcb4a5..5924c90eab1d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2143,6 +2143,8 @@ struct super_operations { #define S_CASEFOLD (1 << 15) /* Casefolded file */ #define S_VERITY (1 << 16) /* Verity file (using fs/verity/) */ #define S_KERNEL_FILE (1 << 17) /* File is in use by the kernel (eg. fs/cachefiles) */ +#define S_PENDING_TIME (1 << 18) /* File update time is pending */ + /* * Note that nosuid etc flags are inode-specific: setting some file-system @@ -2185,6 +2187,7 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_ENCRYPTED(inode) ((inode)->i_flags & S_ENCRYPTED) #define IS_CASEFOLDED(inode) ((inode)->i_flags & S_CASEFOLD) #define IS_VERITY(inode) ((inode)->i_flags & S_VERITY) +#define IS_PENDING_TIME(inode) ((inode)->i_flags & S_PENDING_TIME) #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV)