From patchwork Fri Aug 25 13:54:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365808 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 4372FC71133 for ; Fri, 25 Aug 2023 13:59:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D5BC2800C8; Fri, 25 Aug 2023 09:59:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 383428E0019; Fri, 25 Aug 2023 09:59:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2242B2800C8; Fri, 25 Aug 2023 09:59:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 044438E0019 for ; Fri, 25 Aug 2023 09:59:55 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DFCF6B268C for ; Fri, 25 Aug 2023 13:59:54 +0000 (UTC) X-FDA: 81162785508.25.556F6C3 Received: from out-249.mta1.migadu.com (out-249.mta1.migadu.com [95.215.58.249]) by imf21.hostedemail.com (Postfix) with ESMTP id 314E81C000F for ; Fri, 25 Aug 2023 13:59:52 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=KOUX30U5; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf21.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.249 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971993; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WRD02daxOp9FNChzaFYS1lXdVleuK5a0no8X9tPyoYM=; b=Jk6NaHNj/c/jOs8Z2YEx5vtGEnMVw+SfyLtqvuadneFh8/dAfLnRJkVo3Uh54hh61Pc7ie zaqkjNjVwv62+KUiIyBtCqZ4RdtkvCp8OJoPPNhvPsOYX28rFX13K0P3OVaXU+IusUbR71 lr+DJNl4g2VSy23q0Cduu/bf+PObh9k= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=KOUX30U5; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf21.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.249 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971993; a=rsa-sha256; cv=none; b=iI5IHFj0S9HsXkt0fIHtLRUAsCa42vrVUQt36ZNVwu4y73L0OPmpxMhlUVcqwVGTqsfl9N RcPWxUOaCV5zW5cjhATwrKvnlBJYQoH3NGw36Ck30wWN5fpz3D52HlHJCLaaEEsY09Z60/ 1uR/2Xa4fKO6tBW01flfUcNIn1rboAg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692971991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WRD02daxOp9FNChzaFYS1lXdVleuK5a0no8X9tPyoYM=; b=KOUX30U5aMel7ZOrU6vyW+bfFawd12zc010HOkye0FIA5XwWQ8KuInrnnmEFvcM8/s51Q/ AaOybn5P1rP9UUeek73yc4I2uwInaXUHDAuF9iPRuAYZ+C8EXUIDSwZm4Bf0ZiLG750HKq BEWS22oRahJI/f4a4TxHtu+cFMHMdVg= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 10/29] vfs: add S_NOWAIT for nowait time update Date: Fri, 25 Aug 2023 21:54:12 +0800 Message-Id: <20230825135431.1317785-11-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Stat-Signature: prxrs788xaentdas755uqijpf4hceqyw X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 314E81C000F X-HE-Tag: 1692971992-59919 X-HE-Meta: U2FsdGVkX1/JukW8dcuHUqzZq3AMmFGuwKmuuXeGw6d98j/OvB+rTSI+OO2SYm09Fc1Ix1Vaf/aDR8aGCS+POVZ7+TPzD9oP6YZWQ7KUNhnY7PDvi0ui6KZHCXefZOumZTcAz+VKECiCmMjSuJf2MbMYpgjYXC5oCghM6wOTJOFx3Duh5NcP0z8ACRbzBdX02yUd+txWibvHr5VaY5Nz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m@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Add a new time flag S_NOWAIT to support nowait time update. Deliver it to specific filesystem and error out -EAGAIN when it would block. Signed-off-by: Hao Xu --- fs/inode.c | 9 +++++---- fs/xfs/xfs_iops.c | 8 +++++++- include/linux/fs.h | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index e83b836f2d09..eb3db34a3e6e 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1966,12 +1966,13 @@ int touch_atime(const struct path *path, bool nowait) struct vfsmount *mnt = path->mnt; struct inode *inode = d_inode(path->dentry); struct timespec64 now; + int ret = 0; if (!atime_needs_update(path, inode)) - return 0; + return ret; if (!sb_start_write_trylock(inode->i_sb)) - return 0; + return ret; if (__mnt_want_write(mnt) != 0) goto skip_update; @@ -1985,11 +1986,11 @@ int touch_atime(const struct path *path, bool nowait) * of the fs read only, e.g. subvolumes in Btrfs. */ now = current_time(inode); - inode_update_time(inode, &now, S_ATIME); + ret = inode_update_time(inode, &now, S_ATIME | (nowait ? S_NOWAIT : 0)); __mnt_drop_write(mnt); skip_update: sb_end_write(inode->i_sb); - return 0; + return ret; } EXPORT_SYMBOL(touch_atime); diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 24718adb3c16..bf1d4c31f009 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1053,7 +1053,13 @@ xfs_vn_update_time( if (error) return error; - xfs_ilock(ip, XFS_ILOCK_EXCL); + if (flags & S_NOWAIT) { + if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) + return -EAGAIN; + } else { + xfs_ilock(ip, XFS_ILOCK_EXCL); + } + if (flags & S_CTIME) inode->i_ctime = *now; if (flags & S_MTIME) diff --git a/include/linux/fs.h b/include/linux/fs.h index ed60b3d70d1e..f8c267ee5cb7 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2198,6 +2198,7 @@ enum file_time_flags { S_MTIME = 2, S_CTIME = 4, S_VERSION = 8, + S_NOWAIT = 16, }; extern bool atime_needs_update(const struct path *, struct inode *);