Received: by 10.192.165.156 with SMTP id m28csp2093325imm; Thu, 12 Apr 2018 08:30:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx48RBXUHp8SLX4j750AZ6utRClClAFffmov81pBABwwXSFl7u1qiFPkEFYbSSK4BTamexPBl X-Received: by 2002:a17:902:f24:: with SMTP id 33-v6mr1554266ply.242.1523547018238; Thu, 12 Apr 2018 08:30:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523547018; cv=none; d=google.com; s=arc-20160816; b=Tx619WA17uNu2+2yQgNZU4Ik2vVjowzh/Ypg3Pfm3sOVSMwyKmnb0x4iwZ219z7JGs zUni+F1/+61Km0/JFNOqsQCTg0PvDcebFEjagNGOgNT5G147hobMUOwcgjFexvOTz5rF SaaIzdJFUBW7KZgM3dfL2CXR3YfSd03Vl0rSxklp1Wp06bovedLgn7s8Z429vAo/8+9U zyyau/9bGvNI0iF5M4GTKYCpE6NGp3qHa9QSsvW8VGNKvMYrp5xP9bzNG7nPDyPd089B LSoU2ib7akfXw4vTnZ2NxZPhZ0xv9IJ8fAAxT8MkbzYUB49FlzniAK4YNN7BYFL3IoFx pmKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=7iOJrU0S2IjftfJeTpaKvC6bpOTgiemrIHDIwhx9xW4=; b=h92ORm+zLZMgUxuglV3zlg6KBvt8HZnu+dZJZ1AcSMERzBbhcnO02BUHNhcvg/y4iP XqkJinZMiPuHywc9+HyUWWxQszBouSLWDjIc7b7yhnT6lDMoZDzEIsUmABvHx+Ds0DTZ sYcSafv0it99ePbLkEQ1qXR7hZKFw1ts40+M+hXbCk4fY5Z7XeSdc6MnXiRv65jnIgIV c9PkjKgOke9oenBfb08IROZYc7TEF4WpvQouSw6nc59Fx65ZUj2gPE+hkpf3W5pXosZw UWHTry5p7Bny4H5Arn0ablpNNgP7+LckEnnZbNnSWRL/OXlR1tv6xTywdwknw0lTXxPw JizQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10-v6si3690362plr.123.2018.04.12.08.29.41; Thu, 12 Apr 2018 08:30:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754039AbeDLPZM (ORCPT + 99 others); Thu, 12 Apr 2018 11:25:12 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40677 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753202AbeDLPIh (ORCPT ); Thu, 12 Apr 2018 11:08:37 -0400 Received: by mail-wm0-f68.google.com with SMTP id x4so10151391wmh.5 for ; Thu, 12 Apr 2018 08:08:37 -0700 (PDT) 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; bh=7iOJrU0S2IjftfJeTpaKvC6bpOTgiemrIHDIwhx9xW4=; b=Baj32qYcigD5xRtpNJabLl3AtJARL2wfLZgPr0Ad61lYT/9QACHgVOjIs/14eohVSZ Mj3ZFCJd7RRr6V3vMBkGU9w3FzhQTXqSRg0S0Oc2R214/IuYhKKJNzni6pbeBYpRuRna Cl6CqTBj1OOKaqAemVMZxCo9MwrtHMhr27FhvX3NRL5zR35cmmh10xBmvo0EJXDVLJ/l 0fTzK84AsI301003dyU9i0b1QUUrP3O8nMkto1KPTFWeiJ3u+lHYpZTtfoVHLzb2IoUt nJx026JtsMvD8w+cRVivE/Lba8qfq1Jk9bOosVwRQu3lwNxZkZFB6mhGlUjuI37VZdJT OXHg== X-Gm-Message-State: ALQs6tBmbU/zaBW22k44Cfv+0/S3oAPpqDlAb7r2BF1ckZ+sRS98Yq8V 6ZBDI4L14VwLWdpn/YqOzXoDtoqiZH0= X-Received: by 10.28.150.71 with SMTP id y68mr1071204wmd.139.1523545716320; Thu, 12 Apr 2018 08:08:36 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id p197sm2621783wme.43.2018.04.12.08.08.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 08:08:35 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 04/35] ovl: copy up times Date: Thu, 12 Apr 2018 17:07:55 +0200 Message-Id: <20180412150826.20988-5-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180412150826.20988-1-mszeredi@redhat.com> References: <20180412150826.20988-1-mszeredi@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Copy up mtime and ctime to overlay inode after times in real object are modified. Be careful not to dirty cachelines when not necessary. This is in preparation for moving overlay functionality out of the VFS. This patch shouldn't have any observable effect. Signed-off-by: Miklos Szeredi --- fs/overlayfs/dir.c | 5 +++++ fs/overlayfs/inode.c | 1 + fs/overlayfs/overlayfs.h | 7 +++++++ fs/overlayfs/util.c | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 839709c7803a..cd0fa2363723 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -507,6 +507,7 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode, else err = ovl_create_over_whiteout(dentry, inode, attr, hardlink); + ovl_copytimes_with_parent(dentry); } out_revert_creds: revert_creds(old_cred); @@ -768,6 +769,7 @@ static int ovl_do_remove(struct dentry *dentry, bool is_dir) drop_nlink(dentry->d_inode); } ovl_nlink_end(dentry, locked); + ovl_copytimes_with_parent(dentry); out_drop_write: ovl_drop_write(dentry); out: @@ -1079,6 +1081,9 @@ static int ovl_rename(struct inode *olddir, struct dentry *old, ovl_dentry_version_inc(new->d_parent, ovl_type_origin(old) || (d_inode(new) && ovl_type_origin(new))); + ovl_copytimes_with_parent(old); + ovl_copytimes_with_parent(new); + out_dput: dput(newdentry); out_dput_old: diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 6e3815fb006b..33635106c5f7 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -303,6 +303,7 @@ int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char *name, err = vfs_removexattr(realdentry, name); } revert_creds(old_cred); + ovl_copytimes(d_inode(dentry)); out_drop_write: ovl_drop_write(dentry); diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index e0b7de799f6b..eef720ef0f07 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -258,6 +258,13 @@ bool ovl_need_index(struct dentry *dentry); int ovl_nlink_start(struct dentry *dentry, bool *locked); void ovl_nlink_end(struct dentry *dentry, bool locked); int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir); +void ovl_copytimes(struct inode *inode); + +static inline void ovl_copytimes_with_parent(struct dentry *dentry) +{ + ovl_copytimes(d_inode(dentry)); + ovl_copytimes(d_inode(dentry->d_parent)); +} static inline bool ovl_is_impuredir(struct dentry *dentry) { diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 6f1078028c66..11e62e70733a 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -675,3 +675,22 @@ int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir) pr_err("overlayfs: failed to lock workdir+upperdir\n"); return -EIO; } + +void ovl_copytimes(struct inode *inode) +{ + struct inode *upperinode; + + if (!inode) + return; + + upperinode = ovl_inode_upper(inode); + + if (!upperinode) + return; + + if ((!timespec_equal(&inode->i_mtime, &upperinode->i_mtime) || + !timespec_equal(&inode->i_ctime, &upperinode->i_ctime))) { + inode->i_mtime = upperinode->i_mtime; + inode->i_ctime = upperinode->i_ctime; + } +} -- 2.14.3