From mboxrd@z Thu Jan 1 00:00:00 1970 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 48DF4C433EF for ; Thu, 2 Jun 2022 09:00:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0A2B6B0071; Thu, 2 Jun 2022 05:00:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB5E96B0072; Thu, 2 Jun 2022 05:00:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9570D6B0073; Thu, 2 Jun 2022 05:00:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 83A016B0071 for ; Thu, 2 Jun 2022 05:00:01 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 32D3D34688 for ; Thu, 2 Jun 2022 09:00:01 +0000 (UTC) X-FDA: 79532698602.12.0FE7D40 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf06.hostedemail.com (Postfix) with ESMTP id 96CB3180058 for ; Thu, 2 Jun 2022 08:59:56 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 359921F896; Thu, 2 Jun 2022 08:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1654160399; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8ijo1/KEHcpVXOlVT44hrqS2IKLNCLVEBAwl1vFY0TA=; b=DD0J5dXdELDAuit1IL7OilJ6UQT9W/wwLcjy8W8o4G4lqsTGSvrwQWEarnEtVrZKH7vzNe htSZjAVyrxWFfQ1gBUS+j+EILArB9VOOe145jGMe+1UPeFsxNdxs2PIEDVRYtCEDSCtMpY 1vkbNsvKCuE7lrPVdaWxH8jcJNZl8hI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1654160399; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8ijo1/KEHcpVXOlVT44hrqS2IKLNCLVEBAwl1vFY0TA=; b=P/L0tiYJhwQapcna9rCHSysbiguI1WylnEANvICiQU0B5K89dnuVBmGkvNhOWelzNY59nf IkrXxLO6bxgZPUAA== Received: from quack3.suse.cz (unknown [10.100.224.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 20B852C141; Thu, 2 Jun 2022 08:59:59 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id BFC14A0633; Thu, 2 Jun 2022 10:59:58 +0200 (CEST) Date: Thu, 2 Jun 2022 10:59:58 +0200 From: Jan Kara To: Stefan Roesch Cc: io-uring@vger.kernel.org, kernel-team@fb.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, david@fromorbit.com, jack@suse.cz, hch@infradead.org, axboe@kernel.dk Subject: Re: [PATCH v7 11/15] fs: Optimization for concurrent file time updates. Message-ID: <20220602085958.z2gosfb3ul7fa4o3@quack3.lan> References: <20220601210141.3773402-1-shr@fb.com> <20220601210141.3773402-12-shr@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220601210141.3773402-12-shr@fb.com> X-Rspamd-Queue-Id: 96CB3180058 X-Stat-Signature: f58xdusbdops8orhukm5o194j153q1ge X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=DD0J5dXd; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="P/L0tiYJ"; spf=pass (imf06.hostedemail.com: domain of jack@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none X-Rspamd-Server: rspam08 X-HE-Tag: 1654160396-80536 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: On Wed 01-06-22 14:01:37, Stefan Roesch wrote: > 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 Thinking about this, there is a snag with this S_PENDING_TIME scheme. It can happen that we report write as completed to userspace before timestamps are actually updated. So following stat(2) can still return old time stamp which might confuse some userspace application. It might be even nastier with i_version which is used by NFS and can thus cause data consistency issues for NFS. Honza > --- > 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 553e57ec3efa..15f9a7beba55 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -2151,6 +2151,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 > @@ -2193,6 +2195,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) > -- > 2.30.2 > -- Jan Kara SUSE Labs, CR