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 1A984C43334 for ; Thu, 2 Jun 2022 08:44:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A6E946B0072; Thu, 2 Jun 2022 04:44:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1A386B0073; Thu, 2 Jun 2022 04:44:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B89A6B0074; Thu, 2 Jun 2022 04:44:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7B7936B0072 for ; Thu, 2 Jun 2022 04:44:56 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 56A8980AF4 for ; Thu, 2 Jun 2022 08:44:56 +0000 (UTC) X-FDA: 79532660592.17.5BF895C Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf11.hostedemail.com (Postfix) with ESMTP id 74FB14004F for ; Thu, 2 Jun 2022 08:44:47 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D138421B24; Thu, 2 Jun 2022 08:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1654159494; 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=S2GAifzgoN5qperBFrPRQqqXGrgJ2Ve4bhJ9JZz2TjQ=; b=1ZYukKT+NhPuSmeueIcsKDqNOufRFsNPY/kw5uOtt5anATUAbbS6l8ZNuCBNb+SOD8VXiq GYxFoGa2i3Dgn9rbTd3esYgGdvpzVXFHg03yQZZ8ej5AFCtgCnFZHDWaHG5ESSsiN0lkBs SO/C7Z/SzrJe0Pe9KZx/vnPF1J9Xg8s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1654159494; 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=S2GAifzgoN5qperBFrPRQqqXGrgJ2Ve4bhJ9JZz2TjQ=; b=323tc8bIu3tL/1FOjB5RYKBrHju575zOeDEXKvZv0sRYcMkPtcAyzMEt9RqQGtuj8eH5cc NPutDATJm8rAkTDw== 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 BD1A52C141; Thu, 2 Jun 2022 08:44:54 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id 6899CA0633; Thu, 2 Jun 2022 10:44:54 +0200 (CEST) Date: Thu, 2 Jun 2022 10:44:54 +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, Christoph Hellwig Subject: Re: [PATCH v7 10/15] fs: Add async write file modification handling. Message-ID: <20220602084454.2uj4ehvzm3eav5ww@quack3.lan> References: <20220601210141.3773402-1-shr@fb.com> <20220601210141.3773402-11-shr@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220601210141.3773402-11-shr@fb.com> X-Stat-Signature: utu531ys7ey8fguj58131u1wgrzfiw4s X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=1ZYukKT+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=323tc8bI; spf=pass (imf11.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 74FB14004F X-HE-Tag: 1654159487-236908 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:36, Stefan Roesch wrote: > This adds a file_modified_async() function to return -EAGAIN if the > request either requires to remove privileges or needs to update the file > modification time. This is required for async buffered writes, so the > request gets handled in the io worker of io-uring. > > Signed-off-by: Stefan Roesch > Reviewed-by: Christoph Hellwig Looks good to me. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/inode.c | 43 +++++++++++++++++++++++++++++++++++++++++-- > include/linux/fs.h | 1 + > 2 files changed, 42 insertions(+), 2 deletions(-) > > diff --git a/fs/inode.c b/fs/inode.c > index c44573a32c6a..4503bed063e7 100644 > --- a/fs/inode.c > +++ b/fs/inode.c > @@ -2116,17 +2116,21 @@ int file_update_time(struct file *file) > EXPORT_SYMBOL(file_update_time); > > /** > - * file_modified - handle mandated vfs changes when modifying a file > + * file_modified_flags - handle mandated vfs changes when modifying a file > * @file: file that was modified > + * @flags: kiocb flags > * > * When file has been modified ensure that special > * file privileges are removed and time settings are updated. > * > + * If IOCB_NOWAIT is set, special file privileges will not be removed and > + * time settings will not be updated. It will return -EAGAIN. > + * > * Context: Caller must hold the file's inode lock. > * > * Return: 0 on success, negative errno on failure. > */ > -int file_modified(struct file *file) > +static int file_modified_flags(struct file *file, int flags) > { > int ret; > struct inode *inode = file_inode(file); > @@ -2146,11 +2150,46 @@ int file_modified(struct file *file) > ret = inode_needs_update_time(inode, &now); > if (ret <= 0) > return ret; > + if (flags & IOCB_NOWAIT) > + return -EAGAIN; > > return __file_update_time(file, &now, ret); > } > + > +/** > + * file_modified - handle mandated vfs changes when modifying a file > + * @file: file that was modified > + * > + * When file has been modified ensure that special > + * file privileges are removed and time settings are updated. > + * > + * Context: Caller must hold the file's inode lock. > + * > + * Return: 0 on success, negative errno on failure. > + */ > +int file_modified(struct file *file) > +{ > + return file_modified_flags(file, 0); > +} > EXPORT_SYMBOL(file_modified); > > +/** > + * kiocb_modified - handle mandated vfs changes when modifying a file > + * @iocb: iocb that was modified > + * > + * When file has been modified ensure that special > + * file privileges are removed and time settings are updated. > + * > + * Context: Caller must hold the file's inode lock. > + * > + * Return: 0 on success, negative errno on failure. > + */ > +int kiocb_modified(struct kiocb *iocb) > +{ > + return file_modified_flags(iocb->ki_filp, iocb->ki_flags); > +} > +EXPORT_SYMBOL_GPL(kiocb_modified); > + > int inode_needs_sync(struct inode *inode) > { > if (IS_SYNC(inode)) > diff --git a/include/linux/fs.h b/include/linux/fs.h > index bdf1ce48a458..553e57ec3efa 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -2392,6 +2392,7 @@ static inline void file_accessed(struct file *file) > } > > extern int file_modified(struct file *file); > +int kiocb_modified(struct kiocb *iocb); > > int sync_inode_metadata(struct inode *inode, int wait); > > -- > 2.30.2 > -- Jan Kara SUSE Labs, CR