From patchwork Thu Feb 14 10:00:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 412EE13B5 for ; Thu, 14 Feb 2019 10:01:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3250A2CD1B for ; Thu, 14 Feb 2019 10:01:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 269AF2CD91; Thu, 14 Feb 2019 10:01:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96AEC2CD1B for ; Thu, 14 Feb 2019 10:01:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437826AbfBNKBB (ORCPT ); Thu, 14 Feb 2019 05:01:01 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37616 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393498AbfBNKBA (ORCPT ); Thu, 14 Feb 2019 05:01:00 -0500 Received: by mail-pf1-f194.google.com with SMTP id s22so2855312pfh.4 for ; Thu, 14 Feb 2019 02:01:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EVYMogBI4jH/67Zve0CCKF3qzn61yTaO8kNdGkw2lp0=; b=B5qmejP/7w2oWJWv/oV+8ZrB5ZN6/sze+t3hgFWrfkCM7axsOBafeMe9/ZeE1Vejqe oOkE46QjKxER2iUcnFlonsqAt94w6CKsARtz/U4VeGPISvM2VP9V24Y3CvUtwX2PnOhl RSUeuGmLajavqOBDi5ZRXL+RM8q/MtTyWdkzZSNc/+X7/1j5rn/J8Hdfw0H9Oh6Ca8z2 jOJLTa/fgDTVhff6K2+G1uIaRXXtvgbZivToTzeGOKfn1/UBdwK2jTYDDV8z+ycyDnh+ ASYhZfS4R0LMXt4O2vy9CyoSxtW9WhXeiwwwSyGC0BhavoWWNu8nMKSENkYpf9IXVwIV mIpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EVYMogBI4jH/67Zve0CCKF3qzn61yTaO8kNdGkw2lp0=; b=hgiDxcddFmxYbVxKhCCsWUWzws9oXxkijQmOdwl5c/vJC+mGA//R4sXUwOT6qq4TIl m+Yrho7H0d9bFrUg5i6GfaosqQ6E/R5RquigyTzmGS2tGD2EzYsHs6yhVaoqNdczVYuE h+D++teZfFcujCld1FDZvBbFTmBsdXBbUxeKGZoMPo2wvgRGyVu5ThedrGFJilB1L9XD rTaCusHwfqkOwpahzq9a9YikYmpYUyPmwav1nXwKiH+rcCgMFnUJOrxukHrPMipfVTRv HUNdECzu7GItQCnEGv99kBw+5NbHZ1O1rDGtxYytBzC9255w+zCkUFKWKvfnUqUx7aU1 4RMA== X-Gm-Message-State: AHQUAuaBZkFkOShOaC/nRlXZz1fxhyfXteh4t5tx0vzrQK8J6vrnL1e5 61SBtRNCPwdHy1XfsCarhsUVwg== X-Google-Smtp-Source: AHgI3IYIKRGtWY+ZPKyvM7X4BGw9YR0Xss1EIlbxjpL9e1+gb7kdRN23yFkXwhVxYi1FPJUsq1SPHw== X-Received: by 2002:a63:7044:: with SMTP id a4mr2852696pgn.359.1550138459914; Thu, 14 Feb 2019 02:00:59 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:5849]) by smtp.gmail.com with ESMTPSA id i184sm2686952pfc.41.2019.02.14.02.00.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:00:59 -0800 (PST) From: Omar Sandoval To: linux-fsdevel@vger.kernel.org, Al Viro Cc: kernel-team@fb.com, linux-api@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org Subject: [RFC PATCH 1/6] fs: add btime to struct iattr Date: Thu, 14 Feb 2019 02:00:08 -0800 Message-Id: <338b960e32ae2bebcf45c738af42a979af112e12.1550136164.git.osandov@fb.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval Add btime as an attribute that can be updated through notify_change() if the filesystem supports it, which is indicated by FS_HAS_BTIME in file_system_type->fs_flags. Signed-off-by: Omar Sandoval --- fs/attr.c | 6 ++++++ include/linux/fs.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/fs/attr.c b/fs/attr.c index d22e8187477f..4831ef479951 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -233,6 +233,10 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de WARN_ON_ONCE(!inode_is_locked(inode)); + if ((ia_valid & ATTR_BTIME) && + !(inode->i_sb->s_type->fs_flags & FS_HAS_BTIME)) + return -EOPNOTSUPP; + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) { if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) return -EPERM; @@ -267,6 +271,8 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de attr->ia_atime = now; if (!(ia_valid & ATTR_MTIME_SET)) attr->ia_mtime = now; + if (!(ia_valid & ATTR_BTIME_SET)) + attr->ia_btime = now; if (ia_valid & ATTR_KILL_PRIV) { error = security_inode_need_killpriv(dentry); if (error < 0) diff --git a/include/linux/fs.h b/include/linux/fs.h index 29d8e2cfed0e..d66040f7740b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -191,6 +191,8 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */ #define ATTR_TIMES_SET (1 << 16) #define ATTR_TOUCH (1 << 17) +#define ATTR_BTIME (1 << 18) +#define ATTR_BTIME_SET (1 << 19) /* * Whiteout is represented by a char device. The following constants define the @@ -217,6 +219,7 @@ struct iattr { struct timespec64 ia_atime; struct timespec64 ia_mtime; struct timespec64 ia_ctime; + struct timespec64 ia_btime; /* * Not an attribute, but an auxiliary info for filesystems wanting to @@ -2172,6 +2175,7 @@ struct file_system_type { #define FS_BINARY_MOUNTDATA 2 #define FS_HAS_SUBTYPE 4 #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ +#define FS_HAS_BTIME 16 /* Supports getting/setting btime. */ #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ struct dentry *(*mount) (struct file_system_type *, int, const char *, void *); From patchwork Thu Feb 14 10:00:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3356513B4 for ; Thu, 14 Feb 2019 10:01:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 237182CCF3 for ; Thu, 14 Feb 2019 10:01:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17BEB2CD1B; Thu, 14 Feb 2019 10:01:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8527E2CCF3 for ; Thu, 14 Feb 2019 10:01:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437940AbfBNKBC (ORCPT ); Thu, 14 Feb 2019 05:01:02 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41679 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437904AbfBNKBC (ORCPT ); Thu, 14 Feb 2019 05:01:02 -0500 Received: by mail-pg1-f195.google.com with SMTP id m1so2804328pgq.8 for ; Thu, 14 Feb 2019 02:01:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TLQAdFNP+15JxlBI58SJ2nT9uYeBUgqzimf4OUiFWJc=; b=IC+Wyo0IblsVFiSxEyjsJ8rnNo4ZvFfbYe60h5J4MsnrTKmn8TyLuRtQ1Z6Zmk3yFI gDz8YNGyAeIFrwstdiGIgatkfHW2AtUZmiTLOGV2q1w0VKJtY/gRJV52e1m+udXWip14 vWOSbmdzrkLF6EIpA1ydbJesfE14v7+vsr8KYdMPYrf8lYB0xvW6vkmXi7TSeIkfiLbk 0775oHCg06HBHFqHWSN1RW8gr1ORZ/mCSAVcYy0mWBFlVDpUUTCsGG42Rw7c0eC32YjI 65RA51epvsDCsYUs0entnyQCn6es1hjZ/KnnR8kQR1VFRU/WnYs3k95VuN9a05T1GEJm mVpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TLQAdFNP+15JxlBI58SJ2nT9uYeBUgqzimf4OUiFWJc=; b=UI10H00m/Yiu1Bo24cwnfTFJRVboZ9A/TUlMxtrNVJGk1xx3OfcRF6SqAS0c0CzAOR F/DvGpG5fuXLC6o6TUXvEFjQXipWg9+ja9GX9nSSrxEYsqwXBIF+6zif2plQV2bvXdoK HlD4PFhTEHxNqgBe4z6t8G99IISsSmBcQRcbFwXpjbxEe2DxTvTTbdVb0K9IMa7jkDnz 91xh4cI1/dZynbPn8M7mjuR55UElsgroaJfFWXPIZWpFXPOiPkO/MOX77A/bRTE5NehB qtEwaLcxZZmX1LxeNvufJ4bOUDAHf1Rivn5BxAVIdwL1VRIRIgBBJzCbRdFjwegh12NL XQ7w== X-Gm-Message-State: AHQUAuZc/kmcz2R5SrI+9cdHERV8GRkk7tm0J4Fgc1H+NeM6rxOYP+5t atZl7FEbHnejJeMTQ+JQqtqu3w== X-Google-Smtp-Source: AHgI3IaIZF8cQSfl1R7Zn9umrjvXrfwkmwtV4dKUogKICaSr3GY9IdmWyNzAWtPOpu9FRk7Pxl9Bog== X-Received: by 2002:a63:4e1d:: with SMTP id c29mr2961796pgb.433.1550138461256; Thu, 14 Feb 2019 02:01:01 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:5849]) by smtp.gmail.com with ESMTPSA id i184sm2686952pfc.41.2019.02.14.02.01.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:01:00 -0800 (PST) From: Omar Sandoval To: linux-fsdevel@vger.kernel.org, Al Viro Cc: kernel-team@fb.com, linux-api@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org Subject: [RFC PATCH 2/6] fs: add AT_UTIME_BTIME for utimensat() Date: Thu, 14 Feb 2019 02:00:09 -0800 Message-Id: <383aea1b93edf69d4f96a898ef4878881867d33e.1550136164.git.osandov@fb.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval Now that we have a btime iattr, use it to allow updating btime from utimensat(). We do so by adding a new AT_UTIME_BTIME flag. Iff this flag is given, the btime is set to times[2] (unless times is NULL, in which case the current time is used). Signed-off-by: Omar Sandoval --- fs/utimes.c | 86 +++++++++++++++++++++++--------------- include/uapi/linux/fcntl.h | 2 + 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/fs/utimes.c b/fs/utimes.c index bdcf2daf39c1..cb9fe77e5f91 100644 --- a/fs/utimes.c +++ b/fs/utimes.c @@ -16,7 +16,20 @@ static bool nsec_valid(long nsec) return nsec >= 0 && nsec <= 999999999; } -static int utimes_common(const struct path *path, struct timespec64 *times) +static void init_time_attr(struct iattr *newattrs, struct timespec64 *time_attr, + struct timespec64 time, unsigned int attr, + unsigned int attr_set) +{ + if (time.tv_nsec == UTIME_OMIT) { + newattrs->ia_valid &= ~attr; + } else { + *time_attr = time; + newattrs->ia_valid |= attr_set; + } +} + +static int utimes_common(const struct path *path, struct timespec64 *times, + bool btime) { int error; struct iattr newattrs; @@ -28,25 +41,21 @@ static int utimes_common(const struct path *path, struct timespec64 *times) goto out; if (times && times[0].tv_nsec == UTIME_NOW && - times[1].tv_nsec == UTIME_NOW) + times[1].tv_nsec == UTIME_NOW && + (!btime || times[2].tv_nsec == UTIME_NOW)) times = NULL; newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; + if (btime) + newattrs.ia_valid |= ATTR_BTIME; if (times) { - if (times[0].tv_nsec == UTIME_OMIT) - newattrs.ia_valid &= ~ATTR_ATIME; - else if (times[0].tv_nsec != UTIME_NOW) { - newattrs.ia_atime.tv_sec = times[0].tv_sec; - newattrs.ia_atime.tv_nsec = times[0].tv_nsec; - newattrs.ia_valid |= ATTR_ATIME_SET; - } - - if (times[1].tv_nsec == UTIME_OMIT) - newattrs.ia_valid &= ~ATTR_MTIME; - else if (times[1].tv_nsec != UTIME_NOW) { - newattrs.ia_mtime.tv_sec = times[1].tv_sec; - newattrs.ia_mtime.tv_nsec = times[1].tv_nsec; - newattrs.ia_valid |= ATTR_MTIME_SET; + init_time_attr(&newattrs, &newattrs.ia_atime, times[0], + ATTR_ATIME, ATTR_ATIME_SET); + init_time_attr(&newattrs, &newattrs.ia_mtime, times[1], + ATTR_MTIME, ATTR_MTIME_SET); + if (btime) { + init_time_attr(&newattrs, &newattrs.ia_btime, times[2], + ATTR_BTIME, ATTR_BTIME_SET); } /* * Tell setattr_prepare(), that this is an explicit time @@ -90,14 +99,16 @@ static int utimes_common(const struct path *path, struct timespec64 *times) long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, int flags) { + bool btime = flags & AT_UTIME_BTIME; int error = -EINVAL; if (times && (!nsec_valid(times[0].tv_nsec) || - !nsec_valid(times[1].tv_nsec))) { + !nsec_valid(times[1].tv_nsec) || + (btime && !nsec_valid(times[2].tv_nsec)))) { goto out; } - if (flags & ~AT_SYMLINK_NOFOLLOW) + if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_UTIME_BTIME)) goto out; if (filename == NULL && dfd != AT_FDCWD) { @@ -111,7 +122,7 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, if (!f.file) goto out; - error = utimes_common(&f.file->f_path, times); + error = utimes_common(&f.file->f_path, times, btime); fdput(f); } else { struct path path; @@ -124,7 +135,7 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, if (error) goto out; - error = utimes_common(&path, times); + error = utimes_common(&path, times, btime); path_put(&path); if (retry_estale(error, lookup_flags)) { lookup_flags |= LOOKUP_REVAL; @@ -139,16 +150,20 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, SYSCALL_DEFINE4(utimensat, int, dfd, const char __user *, filename, struct __kernel_timespec __user *, utimes, int, flags) { - struct timespec64 tstimes[2]; + struct timespec64 tstimes[3]; if (utimes) { - if ((get_timespec64(&tstimes[0], &utimes[0]) || - get_timespec64(&tstimes[1], &utimes[1]))) - return -EFAULT; - + int i, n = (flags & AT_UTIME_BTIME) ? 3 : 2; + bool all_omit = true; + + for (i = 0; i < n; i++) { + if (get_timespec64(&tstimes[i], &utimes[i])) + return -EFAULT; + if (tstimes[i].tv_nsec != UTIME_OMIT) + all_omit = false; + } /* Nothing to do, we must not even check the path. */ - if (tstimes[0].tv_nsec == UTIME_OMIT && - tstimes[1].tv_nsec == UTIME_OMIT) + if (all_omit) return 0; } @@ -242,14 +257,19 @@ COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename, COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct old_timespec32 __user *, t, int, flags) { - struct timespec64 tv[2]; + struct timespec64 tv[3]; if (t) { - if (get_old_timespec32(&tv[0], &t[0]) || - get_old_timespec32(&tv[1], &t[1])) - return -EFAULT; - - if (tv[0].tv_nsec == UTIME_OMIT && tv[1].tv_nsec == UTIME_OMIT) + int i, n = (flags & AT_UTIME_BTIME) ? 3 : 2; + bool all_omit = true; + + for (i = 0; i < n; i++) { + if (get_old_timespec32(&tv[i], &t[i])) + return -EFAULT; + if (tv[i].tv_nsec != UTIME_OMIT) + all_omit = false; + } + if (all_omit) return 0; } return do_utimes(dfd, filename, t ? tv : NULL, flags); diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h index 6448cdd9a350..fc5b02439697 100644 --- a/include/uapi/linux/fcntl.h +++ b/include/uapi/linux/fcntl.h @@ -90,5 +90,7 @@ #define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */ #define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */ +#define AT_UTIME_BTIME 0x8000 /* Also update file creation time */ + #endif /* _UAPI_LINUX_FCNTL_H */ From patchwork Thu Feb 14 10:00:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3EF4913B4 for ; Thu, 14 Feb 2019 10:01:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E5EC2CCBE for ; Thu, 14 Feb 2019 10:01:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 221002CCD5; Thu, 14 Feb 2019 10:01:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 215E22CCBE for ; Thu, 14 Feb 2019 10:01:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437929AbfBNKBE (ORCPT ); Thu, 14 Feb 2019 05:01:04 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41686 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438125AbfBNKBD (ORCPT ); Thu, 14 Feb 2019 05:01:03 -0500 Received: by mail-pl1-f196.google.com with SMTP id k15so2896965pls.8 for ; Thu, 14 Feb 2019 02:01:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z1iJdJ3ICufViigzY8ArSNJ8k4Y0JN5jmw8hA8KfmFU=; b=flSeOV67kqykhRwclnrfrqoGKGW89REoU5Hj3g1pDXyBpBurQb2WVbHnHGfaabPXdH eKSDz9iBLVBH6TXcJNKLXZJap0/h8DRGo8G/gzkD0GUDf8FD/etzCzTTEqkkXDFXIdJc hjVZm9tfRGvQNK419c1V7l8hrPfdXq3wlRMPwfjeufOh/yml3DSYcVPBc2pga/OkMVfF nM5e+JjSOCkBu/xCvjduIggPnLBWzR8qLBjq2dQ2IyilRt/iJvogtDrMC9sgrgvNMDFE 490OtH/PMfgJUxT3sDxj3fMVRc2qOHjshCd52BoIM5c8zvZnS82pGDv5tLy8rBbHrWD1 IQIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z1iJdJ3ICufViigzY8ArSNJ8k4Y0JN5jmw8hA8KfmFU=; b=LgdF9ZAXjhKfI8AfsbTre73PDTlEg7juO9iCYUmEd+gKxSIN/oQ98OaXATPcLYkJAd Iv1Ge7I+eJi00sAlBI4KHxDbZ4fo8UJDoI7hUyeiflTjD7b31wsxv3U5Ms5hysTN1Yrf ubtchWdrv379Z/XgYIvi/SgcWAkomgSTv9t2QU9nSGgK7139b08fV2XEmzA/mNTDqSS/ +gVTz2uvADMY8lLVA2r7oveXyJZAfVxU8ALR7KPJbmagiCzoCSJa0ivTlsiK7EQ9dU07 8ptFozPPDKOPcCyiPar7gIy2dvuNjGVNrT132sLmReVNxi33MWjjN8j9owGt1hmIJcDa xSAA== X-Gm-Message-State: AHQUAuaRICf6mrCxAo5JKLmcXMMBPe8xUfIUgV3/FFv1z7PF7DduwSYM wAnX0EFveEYTpVonEOXTnrc0Qg== X-Google-Smtp-Source: AHgI3Ibyqg3SB+jzXjDULbQ1xxmVIWOPdoCIOX55ghDRePdqF29R1HktJeP2hFm85ktvyjbG1CXwlw== X-Received: by 2002:a17:902:31a4:: with SMTP id x33mr3169876plb.198.1550138462471; Thu, 14 Feb 2019 02:01:02 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:5849]) by smtp.gmail.com with ESMTPSA id i184sm2686952pfc.41.2019.02.14.02.01.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:01:01 -0800 (PST) From: Omar Sandoval To: linux-fsdevel@vger.kernel.org, Al Viro Cc: kernel-team@fb.com, linux-api@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org Subject: [RFC PATCH 3/6] Btrfs: add support for setting btime Date: Thu, 14 Feb 2019 02:00:10 -0800 Message-Id: <60b83d5151d3c80bf73bb257b971aeb66120d4d5.1550136164.git.osandov@fb.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval The Btrfs inode format has always included btime (under the name otime), so setting it is trivial. Signed-off-by: Omar Sandoval --- fs/btrfs/inode.c | 2 ++ fs/btrfs/super.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5c349667c761..49ad777d8057 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5153,6 +5153,8 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr) if (attr->ia_valid) { setattr_copy(inode, attr); + if (attr->ia_valid & ATTR_BTIME) + BTRFS_I(inode)->i_otime = attr->ia_btime; inode_inc_iversion(inode); err = btrfs_dirty_inode(inode); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 0a3f122dd61f..2af368cad2aa 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2140,7 +2140,7 @@ static struct file_system_type btrfs_fs_type = { .name = "btrfs", .mount = btrfs_mount, .kill_sb = btrfs_kill_super, - .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA, + .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_HAS_BTIME, }; static struct file_system_type btrfs_root_fs_type = { @@ -2148,7 +2148,7 @@ static struct file_system_type btrfs_root_fs_type = { .name = "btrfs", .mount = btrfs_mount_root, .kill_sb = btrfs_kill_super, - .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA, + .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_HAS_BTIME, }; MODULE_ALIAS_FS("btrfs"); From patchwork Thu Feb 14 10:00:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812299 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 928BF13B5 for ; Thu, 14 Feb 2019 10:01:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 841622CCF3 for ; Thu, 14 Feb 2019 10:01:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 781522CD1B; Thu, 14 Feb 2019 10:01:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4B7B2CCF3 for ; Thu, 14 Feb 2019 10:01:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438205AbfBNKBc (ORCPT ); Thu, 14 Feb 2019 05:01:32 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46020 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438125AbfBNKBF (ORCPT ); Thu, 14 Feb 2019 05:01:05 -0500 Received: by mail-pg1-f194.google.com with SMTP id y4so2799307pgc.12 for ; Thu, 14 Feb 2019 02:01:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IqdSQkcumnBYhLQAnydEDsb1lAsWO+oD/FDDiPGvmEE=; b=usaAmZedAV+G4MMMkgGPc8S28KpQ++l9qQmbxyRM15MIgyq61pe2WF0wQdkEMDo5nH iKWh2WrcoAl6wZ6ERj72OMFr1YD0Wr2wM4HPxT/wzzqFoLQzAgdAB6FKvYj2dxEzINjw N4Cv0xGqzBMYp4G3vzyyY66JoIJEoOCTCZtwaMFmV+MFHuCP+UzKJCq/Tbul625qjjvn xXdzJeyEyRKbXV36HUJtBmgF/6F8lfpicQ9u1cVJMagXEpBHqAxFl7b2omFkpQgnGX81 25cJ8stplZONWlWNtfajsyQl4bJ1sDihwNYSpvXfiAHrvgJNNhDbliQZoNeAWgU0DIc+ d/oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IqdSQkcumnBYhLQAnydEDsb1lAsWO+oD/FDDiPGvmEE=; b=D6Y2AX11r2MqzLz2KDzTcQhxAI0JcNG8EDKrkCKF/jwj1TwESJpyibG7qVdEO7Ny/m n48fZihr5W4TJwobMC3b6gCL7bVl2QjQoOFCRu6RPaSt8lv+6wygDeFno4cIFqKQyV4F i0pmLUHaSJt8hP8y4/wOhHSO3l3AqjaB1wIUtU7QCmFFZ8x/km37OWl0zR0hmAbP7wu0 FdQTFdDXJwiQI3ilvNPLbUZV99/eWMSe9re69ffKztqEfh7rUIfWwXmyZ4lQi38OJYfs vhXdeRovgnBVSK3kof/GMlYUrVfkqnNGD3Xrs6vgFu9rl/cV6jcThrKr+oNEe2a+bRSL Zp1w== X-Gm-Message-State: AHQUAuYTsFOCA8uGr8OPlanVJVB8SW1Ab0Zt9OKAmvf11rsRozd67fhM igSo6n8x3pUwgUVm+GA8Gm+mKQ== X-Google-Smtp-Source: AHgI3Ib+xTdCQe6JlYsBbZpBuVD1MoJoHbkkyFc1cudFBlwMPakWlfu2ZUCo3JTBKeF8E9jagBZ9Iw== X-Received: by 2002:a63:4b60:: with SMTP id k32mr2950896pgl.186.1550138464181; Thu, 14 Feb 2019 02:01:04 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:5849]) by smtp.gmail.com with ESMTPSA id i184sm2686952pfc.41.2019.02.14.02.01.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:01:03 -0800 (PST) From: Omar Sandoval To: linux-fsdevel@vger.kernel.org, Al Viro Cc: kernel-team@fb.com, linux-api@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org Subject: [RFC PATCH 4/6] ext4: add support for setting btime Date: Thu, 14 Feb 2019 02:00:11 -0800 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval The ext4 inode format includes btime (under the name crtime) if the inode is large enough (256 bytes). Signed-off-by: Omar Sandoval --- fs/ext4/inode.c | 15 +++++++++++++-- fs/ext4/super.c | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 34d7e0703cc6..7f4f83ef539d 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5489,6 +5489,13 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode) } } +static bool ext4_inode_has_crtime(struct inode *inode) +{ + struct ext4_inode *raw_inode; + + return EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_crtime); +} + /* * ext4_setattr() * @@ -5520,6 +5527,9 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) int orphan = 0; const unsigned int ia_valid = attr->ia_valid; + if ((ia_valid & ATTR_BTIME) && !ext4_inode_has_crtime(inode)) + return -EOPNOTSUPP; + if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) return -EIO; @@ -5671,6 +5681,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) if (!error) { setattr_copy(inode, attr); + if (ia_valid & ATTR_BTIME) + EXT4_I(inode)->i_crtime = attr->ia_btime; mark_inode_dirty(inode); } @@ -5695,11 +5707,10 @@ int ext4_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags) { struct inode *inode = d_inode(path->dentry); - struct ext4_inode *raw_inode; struct ext4_inode_info *ei = EXT4_I(inode); unsigned int flags; - if (EXT4_FITS_IN_INODE(raw_inode, ei, i_crtime)) { + if (ext4_inode_has_crtime(inode)) { stat->result_mask |= STATX_BTIME; stat->btime.tv_sec = ei->i_crtime.tv_sec; stat->btime.tv_nsec = ei->i_crtime.tv_nsec; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index fb12d3c17c1b..cdd3975de130 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5976,7 +5976,7 @@ static struct file_system_type ext4_fs_type = { .name = "ext4", .mount = ext4_mount, .kill_sb = kill_block_super, - .fs_flags = FS_REQUIRES_DEV, + .fs_flags = FS_REQUIRES_DEV | FS_HAS_BTIME, }; MODULE_ALIAS_FS("ext4"); From patchwork Thu Feb 14 10:00:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C107813BF for ; Thu, 14 Feb 2019 10:01:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF9882CA1A for ; Thu, 14 Feb 2019 10:01:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A30DF2CCD9; Thu, 14 Feb 2019 10:01:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4ED882CA1A for ; Thu, 14 Feb 2019 10:01:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438153AbfBNKBI (ORCPT ); Thu, 14 Feb 2019 05:01:08 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37008 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438142AbfBNKBG (ORCPT ); Thu, 14 Feb 2019 05:01:06 -0500 Received: by mail-pg1-f196.google.com with SMTP id q206so2819609pgq.4 for ; Thu, 14 Feb 2019 02:01:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jgcWZgJ1s++4IqkbKKFPdm3Je4rg2/ot9AJodUrt5Dw=; b=ndqUsyCPjvFocNdflivCZ4Wr3PJ1duzo3UXDuOmetIZ3nvAAp1R56QH3Hm76rEt2p6 rtyU1witWlyDxDG3r2zg5/+sfQ9BSTZwCT0WlhzRYXpviNBenLUW2ADuSw5T+W/G5k5l FFX6mrPFKUv9mGsqfu1NOyUKsnkz8Uo2z4eYv9NGTpioOoWI1LS6rbWcW382TlaLBpjr FSLTe7gJl0E3XPpqb5BOlK/V/ZsEWxYx5WBNQojxn5mgdJGxqDaGYIk2zIhhds5x6bfb N1iTTcCL2kmsAtUZ5+/SrDH15J78MWo5TQve/AvU4K3YSZODeqlcuJfNac7GQyRWGJ4c l+Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jgcWZgJ1s++4IqkbKKFPdm3Je4rg2/ot9AJodUrt5Dw=; b=blcho+R78gUF+8SLrQ49QEG51MhN1J2szrXHZ4G54PiZOwNLTil3Wr4TziDCgJYft1 eG4kqV3+9dxS+dI/V3NiE38EBO6ME2bNEvFCXU8dsN4+aqbIxz89QtL9X9n+RhkkaINb d7B6hD9UDrnbCt7lEc/XjFb4WBWoe5Xv5sUjXhc9kMiv1Z3N7K/JKrnV0jHAq5naOpya u1xDTnNb87bTWkDLgpeU2zDQF5wDrANZI0MHMVv15pvC6TFfCySEhroYkDTf+BdbCdBX CRkTZkWNFAb+fftqk4hQXxci1xQM9x5AIefnP5ZpG+X6j3Txdz/Lg26LjAP8H+h07wR+ 41CQ== X-Gm-Message-State: AHQUAuaSuctLOVoXMHRjHsB4pPA00E4ySFdF0WKePBK1jG38oLna2Llj 9/nN5rXsgbmwor/yGu87FDUdMw== X-Google-Smtp-Source: AHgI3IZW5aU5aO4ZI8ZDs3ZrKqLPsD9EB4vbxqf6ZbgyCQpgUZc33Rsa9YSKgmB9R7kLoSyhnn3T4g== X-Received: by 2002:a65:620c:: with SMTP id d12mr2935714pgv.328.1550138465568; Thu, 14 Feb 2019 02:01:05 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:5849]) by smtp.gmail.com with ESMTPSA id i184sm2686952pfc.41.2019.02.14.02.01.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:01:04 -0800 (PST) From: Omar Sandoval To: linux-fsdevel@vger.kernel.org, Al Viro Cc: kernel-team@fb.com, linux-api@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org Subject: [RFC PATCH 5/6] f2fs: add support for setting btime Date: Thu, 14 Feb 2019 02:00:12 -0800 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval The f2fs inode format includes btime (under the name crtime) if the feature was enabled at mkfs time. Signed-off-by: Omar Sandoval --- fs/f2fs/file.c | 19 +++++++++++++++---- fs/f2fs/super.c | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index bba56b39dcc5..6064d3e42987 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -690,17 +690,23 @@ int f2fs_truncate(struct inode *inode) return 0; } +static bool f2fs_inode_has_crtime(struct inode *inode) +{ + struct f2fs_inode *ri; + + return (f2fs_has_extra_attr(inode) && + f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)) && + F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize, i_crtime)); +} + int f2fs_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags) { struct inode *inode = d_inode(path->dentry); struct f2fs_inode_info *fi = F2FS_I(inode); - struct f2fs_inode *ri; unsigned int flags; - if (f2fs_has_extra_attr(inode) && - f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)) && - F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) { + if (f2fs_inode_has_crtime(inode)) { stat->result_mask |= STATX_BTIME; stat->btime.tv_sec = fi->i_crtime.tv_sec; stat->btime.tv_nsec = fi->i_crtime.tv_nsec; @@ -770,6 +776,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) int err; bool size_changed = false; + if ((attr->ia_valid & ATTR_BTIME) && !f2fs_inode_has_crtime(inode)) + return -EOPNOTSUPP; + if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) return -EIO; @@ -848,6 +857,8 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) } __setattr_copy(inode, attr); + if (attr->ia_valid & ATTR_BTIME) + F2FS_I(inode)->i_crtime = attr->ia_btime; if (attr->ia_valid & ATTR_MODE) { err = posix_acl_chmod(inode, f2fs_get_inode_mode(inode)); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index c46a1d4318d4..e32070c8cb27 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3485,7 +3485,7 @@ static struct file_system_type f2fs_fs_type = { .name = "f2fs", .mount = f2fs_mount, .kill_sb = kill_f2fs_super, - .fs_flags = FS_REQUIRES_DEV, + .fs_flags = FS_REQUIRES_DEV | FS_HAS_BTIME, }; MODULE_ALIAS_FS("f2fs"); From patchwork Thu Feb 14 10:00:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812295 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CC7C13B4 for ; Thu, 14 Feb 2019 10:01:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E2672CCF3 for ; Thu, 14 Feb 2019 10:01:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 225D62CD13; Thu, 14 Feb 2019 10:01:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDBC72CCD9 for ; Thu, 14 Feb 2019 10:01:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438159AbfBNKBW (ORCPT ); Thu, 14 Feb 2019 05:01:22 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42868 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438143AbfBNKBI (ORCPT ); Thu, 14 Feb 2019 05:01:08 -0500 Received: by mail-pf1-f194.google.com with SMTP id n74so2842585pfi.9 for ; Thu, 14 Feb 2019 02:01:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fTk0FyiVC4C7S5X6h/HN++rzsGBLDjcJTciO7DC+crI=; b=y9Yaj6WcgjusayyYM5Aorfv4cGv5yMWbdVWmHpG76OC/LcK0upaLsLOdU4ca14Oxtg /jEZ2O/z/AMEwRW/68k8ycysACwXQAlb4kVmZuSxEsQgq+TttJ12uFsenUy1oofinIJW 584qHI+fSFc2N24PJM5KIksg154F4i734W6DTOUNfJWDRXh2qRl3fGt+xorIOhy0mTAK KBFkVC5Q62yIjyY5D3jNfPtp3Hn9jNL1E9psK50mdleOqVB7v8Tv0ew1yokCP2ZoiFlp Y35OyQFRmzmMw2hZbJBT6uNdwI64QHZisy2cTvIHKv/EAXiHshp5yYfPiCBQAkwusb4D Rgag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fTk0FyiVC4C7S5X6h/HN++rzsGBLDjcJTciO7DC+crI=; b=SNCM0AM3FyIppz4DxxnrzLD0TT1rqueaWGvrimZd9YuHsFH69LshjBQX/vQM+NllWW 4Bw5nFXl4HZzQHGcU/ls6xx4fT1Hn9xnwy4tnFx8egWtfOXjHYZ3WGOSOHQXAqofcnmk zpHyeeeS+ALph2ydXIaCBygXzM4+Yirzt4XTWCp2zNTEkqR5EYitr94AP5UQpxZIhfFr 45stzM46pfu55J4Hlr5vHNUMaLEn+5S4rnUpIJcLQhkwvSblh4TJytz91tMeZo8TLZ1o /J5I3QPbHgGkVEzANPS8tHcGgn1lQkf1yucVe/GopCRhssMgTNwTeLPkQQb61Lel7eqv rCIw== X-Gm-Message-State: AHQUAuZkDDutsqrnpK3pfsU3Vz0SXY4YIAD3n0dKPoA+FyNUug1ZCe1j uuuVnXv3xs+EcD+PEXdiEhih+Q== X-Google-Smtp-Source: AHgI3IZx8Umv7Vjiiq1lW+1CsCbGd8SRwLIkK8mTGw+gp3D0GueHp0jnouvmQm42uVNCErrgJd9ZWg== X-Received: by 2002:a63:2a86:: with SMTP id q128mr2978793pgq.424.1550138467024; Thu, 14 Feb 2019 02:01:07 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:5849]) by smtp.gmail.com with ESMTPSA id i184sm2686952pfc.41.2019.02.14.02.01.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:01:06 -0800 (PST) From: Omar Sandoval To: linux-fsdevel@vger.kernel.org, Al Viro Cc: kernel-team@fb.com, linux-api@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org Subject: [RFC PATCH 6/6] xfs: add support for setting btime Date: Thu, 14 Feb 2019 02:00:13 -0800 Message-Id: <853e0dbdcd881e7dae13ada9dbb5924f6f5c4d9c.1550136164.git.osandov@fb.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval The XFS inode format includes btime (under the name crtime) in inode version 3. Also update the comments in libxfs to reflect that di_crtime can now change. Signed-off-by: Omar Sandoval --- fs/xfs/libxfs/xfs_format.h | 2 +- fs/xfs/libxfs/xfs_log_format.h | 2 +- fs/xfs/xfs_iops.c | 11 +++++++++-- fs/xfs/xfs_super.c | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 9bb3c48843ec..ff6cb860ae77 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -884,9 +884,9 @@ typedef struct xfs_dinode { __be64 di_flags2; /* more random flags */ __be32 di_cowextsize; /* basic cow extent size for file */ __u8 di_pad2[12]; /* more padding for future expansion */ + xfs_timestamp_t di_crtime; /* time created */ /* fields only written to during inode creation */ - xfs_timestamp_t di_crtime; /* time created */ __be64 di_ino; /* inode number */ uuid_t di_uuid; /* UUID of the filesystem */ diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index e5f97c69b320..5cb35b3db870 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -415,9 +415,9 @@ struct xfs_log_dinode { uint64_t di_flags2; /* more random flags */ uint32_t di_cowextsize; /* basic cow extent size for file */ uint8_t di_pad2[12]; /* more padding for future expansion */ + xfs_ictimestamp_t di_crtime; /* time created */ /* fields only written to during inode creation */ - xfs_ictimestamp_t di_crtime; /* time created */ xfs_ino_t di_ino; /* inode number */ uuid_t di_uuid; /* UUID of the filesystem */ diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index f48ffd7a8d3e..20570f61ffeb 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -582,6 +582,10 @@ xfs_setattr_time( inode->i_ctime = iattr->ia_ctime; if (iattr->ia_valid & ATTR_MTIME) inode->i_mtime = iattr->ia_mtime; + if (iattr->ia_valid & ATTR_BTIME) { + ip->i_d.di_crtime.t_sec = iattr->ia_btime.tv_sec; + ip->i_d.di_crtime.t_nsec = iattr->ia_btime.tv_nsec; + } } static int @@ -1025,11 +1029,14 @@ xfs_vn_setattr( struct dentry *dentry, struct iattr *iattr) { + struct inode *inode = d_inode(dentry); + struct xfs_inode *ip = XFS_I(inode); int error; + if ((iattr->ia_valid & ATTR_BTIME) && ip->i_d.di_version != 3) + return -EOPNOTSUPP; + if (iattr->ia_valid & ATTR_SIZE) { - struct inode *inode = d_inode(dentry); - struct xfs_inode *ip = XFS_I(inode); uint iolock; xfs_ilock(ip, XFS_MMAPLOCK_EXCL); diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index c9097cb0b955..54df86bc634b 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1860,7 +1860,7 @@ static struct file_system_type xfs_fs_type = { .name = "xfs", .mount = xfs_fs_mount, .kill_sb = kill_block_super, - .fs_flags = FS_REQUIRES_DEV, + .fs_flags = FS_REQUIRES_DEV | FS_HAS_BTIME, }; MODULE_ALIAS_FS("xfs");