Skip to contentSkip to conversation

Push file_update_time() into .page_mkwrite

PATCH Superseded Jan Kara 8 participants 26 messages Feb 16, 2012 – Feb 29, 2012

Subsystems (14)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

cover Push file_update_time() into .page_mkwrite

Hello,

to provide reliable support for filesystem freezing, filesystems need to have
complete control over when metadata is changed. In particular, file_update_time() calls from page fault code make it impossible for filesystems to prevent inodes from being dirtied while the filesystem is frozen.

To fix the issue, this patch set changes page fault code to call file_update_time() only when ->page_mkwrite() callback is not provided. If the callback is provided, it is the responsibility of the filesystem to perform update of i_mtime / i_ctime if needed. We also push file_update_time() call to all existing ->page_mkwrite() implementations if the time update does not obviously happen by other means. If you know your filesystem does not need update of modification times in ->page_mkwrite() handler, please speak up and I'll drop the patch for your filesystem.

As a side note, an alternative would be to remove call of file_update_time() from page fault code altogether and require all filesystems needing it to do that in their ->page_mkwrite() implementation. That is certainly possible although maybe slightly inefficient and would require auditting 100+ vm_operations_structs *shake*.

If I get acks on these patches, Andrew, would you be willing to take these patches?

Honza

CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
CC Paul Mackerras <[email protected]>
CC Arnaldo Carvalho de Melo <[email protected]>
CC Jaya Kumar <[email protected]>
CC Sage Weil <[email protected]>
CC ceph-devel at vger.kernel.org
CC Steve French <[email protected]>
CC linux-cifs at vger.kernel.org
CC Eric Van Hensbergen <[email protected]>
CC Ron Minnich <[email protected]>
CC Latchesar Ionkov <[email protected]>
CC v9fs-developer at lists.sourceforge.net
CC Miklos Szeredi <[email protected]>
CC fuse-devel at lists.sourceforge.net
CC Steven Whitehouse <[email protected]>
CC cluster-devel at redhat.com
CC Greg Kroah-Hartman <[email protected]>
CC Trond Myklebust <[email protected]>
CC linux-nfs at vger.kernel.org
author reviewer
#1 lore raw

PATCH 1/11 perf: Push file_update_time() into perf_mmap_fault()

CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
CC Paul Mackerras <[email protected]>
CC Arnaldo Carvalho de Melo <[email protected]>
---
 kernel/events/core.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
kernel/events/core.c +3 -1
index ba36013..61a67f3 100644
@@ -3316,8 +3316,10 @@ static int perf_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	int ret = VM_FAULT_SIGBUS;
 
 	if (vmf->flags & FAULT_FLAG_MKWRITE) {
-		if (vmf->pgoff == 0)
+		if (vmf->pgoff == 0) {
 			ret = 0;
+			file_update_time(vma->vm_file);
+		}
 		return ret;
 	}
 
Signature · 8 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#4 lore raw

PATCH 2/11 fb_defio: Push file_update_time() into fb_deferred_io_mkwrite()

In reply to Jan Kara
---
 drivers/video/fb_defio.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/video/fb_defio.c +2 -0
index c27e153..7a09c06 100644
@@ -104,6 +104,8 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
 	deferred framebuffer IO. then if userspace touches a page
 	again, we repeat the same scheme */
 
+	file_update_time(vma->vm_file);
+
 	/* protect against the workqueue changing the page list */
 	mutex_lock(&fbdefio->lock);
 
Signature · 8 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#5 lore raw

PATCH 3/11 fs: Push file_update_time() into __block_page_mkwrite()

In reply to Jan Kara
---
 fs/buffer.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
fs/buffer.c +6 -0
index 1a30db7..5294a33 100644
@@ -2300,6 +2300,12 @@ int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
 	loff_t size;
 	int ret;
 
+	/*
+	 * Update file times before taking page lock. We may end up failing the
+	 * fault so this update may be superfluous but who really cares...
+	 */
+	file_update_time(vma->vm_file);
+
 	lock_page(page);
 	size = i_size_read(inode);
 	if ((page->mapping != inode->i_mapping) ||
Signature · 8 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#6 lore raw

PATCH 4/11 ceph: Push file_update_time() into ceph_page_mkwrite()

In reply to Jan Kara
---
 fs/ceph/addr.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/ceph/addr.c +3 -0
index 173b1d2..12b139f 100644
@@ -1181,6 +1181,9 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	loff_t size, len;
 	int ret;
 
+	/* Update time before taking page lock */
+	file_update_time(vma->vm_file);
+
 	size = i_size_read(inode);
 	if (off + PAGE_CACHE_SIZE <= size)
 		len = PAGE_CACHE_SIZE;
Signature · 8 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#12 lore raw

PATCH 5/11 cifs: Push file_update_time() into cifs_page_mkwrite()

In reply to Jan Kara
---
 fs/cifs/file.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

BTW: How does cifs_page_mkwrite() protect against races with truncate?
See e.g. checks in __block_page_mkwrite()...

fs/cifs/file.c +3 -0
index 4dd9283..8e3b23b 100644
@@ -2425,6 +2425,9 @@ cifs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
 	struct page *page = vmf->page;
 
+	/* Update file times before taking page lock */
+	file_update_time(vma->vm_file);
+
 	lock_page(page);
 	return VM_FAULT_LOCKED;
 }
Signature · 8 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#13 lore raw

PATCH 6/11 9p: Push file_update_time() into v9fs_vm_page_mkwrite()

In reply to Jan Kara
CC Eric Van Hensbergen <[email protected]>
CC Ron Minnich <[email protected]>
CC Latchesar Ionkov <[email protected]>
---
 fs/9p/vfs_file.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

BTW: I see you don't check whether the page you locked isn't beyond i_size.
Cannot your code race with truncate? See checks in __block_page_mkwrite()...

fs/9p/vfs_file.c +3 -0
index fc06fd2..dd6f7ee 100644
@@ -610,6 +610,9 @@ v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	p9_debug(P9_DEBUG_VFS, "page %p fid %lx\n",
 		 page, (unsigned long)filp->private_data);
 
+	/* Update file times before taking page lock */
+	file_update_time(filp);
+
 	v9inode = V9FS_I(inode);
 	/* make sure the cache has finished storing the page */
 	v9fs_fscache_wait_on_page_write(inode, page);
Signature · 8 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#14 lore raw

PATCH 7/11 fuse: Push file_update_time() into fuse_page_mkwrite()

In reply to Jan Kara
---
 fs/fuse/file.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
fs/fuse/file.c +1 -0
index 4a199fd..eade72e 100644
@@ -1323,6 +1323,7 @@ static int fuse_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	 */
 	struct inode *inode = vma->vm_file->f_mapping->host;
 
+	file_update_time(vma->vm_file);
 	fuse_wait_on_page_writeback(inode, page->index);
 	return 0;
 }
Signature · 8 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#15 lore raw

PATCH 8/11 gfs2: Push file_update_time() into gfs2_page_mkwrite()

In reply to Jan Kara
CC Steven Whitehouse <[email protected]>
CC cluster-devel at redhat.com
---
 fs/gfs2/file.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/gfs2/file.c +3 -0
index c5fb359..1f03531 100644
@@ -375,6 +375,9 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	 */
 	vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE);
 
+	/* Update file times before taking page lock */
+	file_update_time(vma->vm_file);
+
 	gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
 	ret = gfs2_glock_nq(&gh);
 	if (ret)
Signature · 1 line
1.7.1
author reviewer
#17 lore raw

PATCH 9/11 sysfs: Push file_update_time() into bin_page_mkwrite()

In reply to Jan Kara
CC Greg Kroah-Hartman <[email protected]>
---
 fs/sysfs/bin.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/sysfs/bin.c +2 -0
index a475983..6ceb16f 100644
@@ -225,6 +225,8 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	if (!sysfs_get_active(attr_sd))
 		return VM_FAULT_SIGBUS;
 
+	file_update_time(file);
+
 	ret = 0;
 	if (bb->vm_ops->page_mkwrite)
 		ret = bb->vm_ops->page_mkwrite(vma, vmf);
Signature · 8 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#22 lore raw

PATCH 10/11 nfs: Push file_update_time() into nfs_vm_page_mkwrite()

In reply to Jan Kara
---
 fs/nfs/file.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/nfs/file.c +3 -0
index c43a452..2407922 100644
@@ -525,6 +525,9 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	/* make sure the cache has finished storing the page */
 	nfs_fscache_wait_on_page_write(NFS_I(dentry->d_inode), page);
 
+	/* Update file times before taking page lock */
+	file_update_time(filp);
+
 	lock_page(page);
 	mapping = page->mapping;
 	if (mapping != dentry->d_inode->i_mapping)
Signature · 1 line
1.7.1
author reviewer
#25 lore raw

PATCH 11/11 mm: Update file times from fault path only if .page_mkwrite is not set

In reply to Jan Kara

Filesystems wanting to properly support freezing need to have control when file_update_time() is called. After pushing file_update_time() to all relevant .page_mkwrite implementations we can just stop calling file_update_time() when filesystem implements .page_mkwrite.

---
 mm/memory.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
mm/memory.c +4 -5
index fa2f04e..17b72d7 100644
@@ -2621,6 +2621,9 @@ reuse:
 		if (!page_mkwrite) {
 			wait_on_page_locked(dirty_page);
 			set_page_dirty_balance(dirty_page, page_mkwrite);
+			/* file_update_time outside page_lock */
+			if (vma->vm_file)
+				file_update_time(vma->vm_file);
 		}
 		put_page(dirty_page);
 		if (page_mkwrite) {
@@ -2638,10 +2641,6 @@ reuse:
 			}
 		}
 
-		/* file_update_time outside page_lock */
-		if (vma->vm_file)
-			file_update_time(vma->vm_file);
-
 		return ret;
 	}
 
@@ -3324,7 +3323,7 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
 		}
 
 		/* file_update_time outside page_lock */
-		if (vma->vm_file)
+		if (vma->vm_file && !page_mkwrite)
 			file_update_time(vma->vm_file);
 	} else {
 		unlock_page(vmf.page);
Signature · 8 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#23 lore raw

Re: [PATCH 10/11] nfs: Push file_update_time() into nfs_vm_page_mkwrite()

In reply to Jan Kara

T24gVGh1LCAyMDEyLTAyLTE2IGF0IDE0OjQ2ICswMTAwLCBKYW4gS2FyYSB3cm90ZToNCj4gQ0M6 IFRyb25kIE15a2xlYnVzdCA8VHJvbmQuTXlrbGVidXN0QG5ldGFwcC5jb20+DQo+IENDOiBsaW51 eC1uZnNAdmdlci5rZXJuZWwub3JnDQo+IFNpZ25lZC1vZmYtYnk6IEphbiBLYXJhIDxqYWNrQHN1 c2UuY3o+DQo+IC0tLQ0KPiAgZnMvbmZzL2ZpbGUuYyB8ICAgIDMgKysrDQo+ICAxIGZpbGVzIGNo YW5nZWQsIDMgaW5zZXJ0aW9ucygrKSwgMCBkZWxldGlvbnMoLSkNCj4gDQo+IGRpZmYgLS1naXQg YS9mcy9uZnMvZmlsZS5jIGIvZnMvbmZzL2ZpbGUuYw0KPiBpbmRleCBjNDNhNDUyLi4yNDA3OTIy IDEwMDY0NA0KPiAtLS0gYS9mcy9uZnMvZmlsZS5jDQo+ICsrKyBiL2ZzL25mcy9maWxlLmMNCj4g QEAgLTUyNSw2ICs1MjUsOSBAQCBzdGF0aWMgaW50IG5mc192bV9wYWdlX21rd3JpdGUoc3RydWN0 IHZtX2FyZWFfc3RydWN0ICp2bWEsIHN0cnVjdCB2bV9mYXVsdCAqdm1mKQ0KPiAgCS8qIG1ha2Ug c3VyZSB0aGUgY2FjaGUgaGFzIGZpbmlzaGVkIHN0b3JpbmcgdGhlIHBhZ2UgKi8NCj4gIAluZnNf ZnNjYWNoZV93YWl0X29uX3BhZ2Vfd3JpdGUoTkZTX0koZGVudHJ5LT5kX2lub2RlKSwgcGFnZSk7 DQo+ICANCj4gKwkvKiBVcGRhdGUgZmlsZSB0aW1lcyBiZWZvcmUgdGFraW5nIHBhZ2UgbG9jayAq Lw0KPiArCWZpbGVfdXBkYXRlX3RpbWUoZmlscCk7DQo+ICsNCj4gIAlsb2NrX3BhZ2UocGFnZSk7 DQo+ICAJbWFwcGluZyA9IHBhZ2UtPm1hcHBpbmc7DQo+ICAJaWYgKG1hcHBpbmcgIT0gZGVudHJ5 LT5kX2lub2RlLT5pX21hcHBpbmcpDQoNCkhpIEphbiwNCg0KZmlsZV91cGRhdGVfdGltZSgpIGlz IGEgbm8tb3AgaW4gTkZTLCBzaW5jZSB3ZSBzZXQgU19OT0FUSU1FfFNfTk9DTVRJTUUNCm9uIGFs bCBpbm9kZXMuDQoNCkNoZWVycw0KICBUcm9uZA0KDQotLSANClRyb25kIE15a2xlYnVzdA0KTGlu dXggTkZTIGNsaWVudCBtYWludGFpbmVyDQoNCk5ldEFwcA0KVHJvbmQuTXlrbGVidXN0QG5ldGFw cC5jb20NCnd3dy5uZXRhcHAuY29tDQoNCg==
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

Re: [PATCH 01/11] perf: Push file_update_time() into perf_mmap_fault()

In reply to Jan Kara
Quoted 14 lines · Jan Kara
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
CC Paul Mackerras <[email protected]>
CC Arnaldo Carvalho de Melo <[email protected]>
---
 kernel/events/core.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
kernel/events/core.c +0 -0
index ba36013..61a67f3 100644

kernel/events/core.c static int perf_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) · line 3324

Quoted 10 lines
kernel/events/core.c +3 -1
@@ -3316,8 +3316,10 @@ static int perf_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	int ret = VM_FAULT_SIGBUS;
 
 	if (vmf->flags & FAULT_FLAG_MKWRITE) {
-		if (vmf->pgoff == 0)
+		if (vmf->pgoff == 0) {
 			ret = 0;
+			file_update_time(vma->vm_file);
+		}
 		return ret;
 	}

Its an anon filedesc, there's no actual file and while I guess one could probably call fstat() on it, people really shouldn't care.

So feel free to introduce this patch to the bitbucket.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer Acked-by on v1 9/11
#18 lore raw

Re: [PATCH 09/11] sysfs: Push file_update_time() into bin_page_mkwrite()

In reply to Jan Kara
Quoted 1 line · Jan Kara
CC Greg Kroah-Hartman <[email protected]>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by on v1 8/11
#16 lore raw

Re: [PATCH 08/11] gfs2: Push file_update_time() into gfs2_page_mkwrite()

In reply to Jan Kara

Hi,

Quoted 7 lines · Jan Kara
---
 fs/gfs2/file.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

That looks ok to me...

Steve.

Quoted 5 lines
fs/gfs2/file.c +0 -0
index c5fb359..1f03531 100644

fs/gfs2/file.c static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 383

Quoted 9 lines
fs/gfs2/file.c +3 -0
@@ -375,6 +375,9 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	 */
 	vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE);
 
+	/* Update file times before taking page lock */
+	file_update_time(vma->vm_file);
+
 	gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
 	ret = gfs2_glock_nq(&gh);
 	if (ret)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw

Re: [PATCH 04/11] ceph: Push file_update_time() into ceph_page_mkwrite()

In reply to Jan Kara
Quoted 3 lines · Jan Kara

This will update the timestamp even if a write
fault fails, which is different from before.

Hard to avoid though.

Looks good to me.

Quoted 8 lines
 fs/ceph/addr.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/ceph/addr.c +0 -0
index 173b1d2..12b139f 100644

fs/ceph/addr.c static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 1189

Quoted 9 lines
fs/ceph/addr.c +3 -0
@@ -1181,6 +1181,9 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	loff_t size, len;
 	int ret;
 
+	/* Update time before taking page lock */
+	file_update_time(vma->vm_file);
+
 	size = i_size_read(inode);
 	if (off + PAGE_CACHE_SIZE <= size)
 		len = PAGE_CACHE_SIZE;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#19 lore raw

Re: [PATCH 09/11] sysfs: Push file_update_time() into bin_page_mkwrite()

In reply to Jan Kara
Quoted 11 lines · Jan Kara
CC Greg Kroah-Hartman <[email protected]>
---
 fs/sysfs/bin.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/sysfs/bin.c +0 -0
index a475983..6ceb16f 100644

fs/sysfs/bin.c static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 232

Quoted 8 lines
fs/sysfs/bin.c +2 -0
@@ -225,6 +225,8 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	if (!sysfs_get_active(attr_sd))
 		return VM_FAULT_SIGBUS;
 
+	file_update_time(file);
+
 	ret = 0;
 	if (bb->vm_ops->page_mkwrite)
 		ret = bb->vm_ops->page_mkwrite(vma, vmf);

If the filesystem's page_mkwrite() function is responsible for updating the time, can't the call to file_update_time() here be conditional?

I.e:

	ret = 0;
	if (bb->vm_ops->page_mkwrite)
 		ret = bb->vm_ops->page_mkwrite(vma, vmf);
	else
		file_update_time(file);

					-Alex

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw

Re: [PATCH 04/11] ceph: Push file_update_time() into ceph_page_mkwrite()

In reply to Alex Elder
Quoted 6 lines · Alex Elder
Quoted 3 lines · Jan Kara
Quoted 6 lines

This will update the timestamp even if a write
fault fails, which is different from before.

Hard to avoid though.

Looks good to me.

Yeah. Let's put something in the tracker to take a look later (I think we can do better), but this is okay for now.

Quoted 29 lines
Quoted 8 lines
 fs/ceph/addr.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/ceph/addr.c +0 -0
index 173b1d2..12b139f 100644

fs/ceph/addr.c static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 1189

Quoted 9 lines
fs/ceph/addr.c +3 -0
@@ -1181,6 +1181,9 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	loff_t size, len;
 	int ret;
 
+	/* Update time before taking page lock */
+	file_update_time(vma->vm_file);
+
 	size = i_size_read(inode);
 	if (off + PAGE_CACHE_SIZE <= size)
 		len = PAGE_CACHE_SIZE;

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author reviewer
#20 lore raw

Re: [PATCH 09/11] sysfs: Push file_update_time() into bin_page_mkwrite()

In reply to Alex Elder
Quoted 25 lines · Alex Elder
Quoted 11 lines · Jan Kara
CC Greg Kroah-Hartman <[email protected]>
---
 fs/sysfs/bin.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/sysfs/bin.c +0 -0
index a475983..6ceb16f 100644

fs/sysfs/bin.c static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 232

Quoted 8 lines
fs/sysfs/bin.c +2 -0
@@ -225,6 +225,8 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	if (!sysfs_get_active(attr_sd))
 		return VM_FAULT_SIGBUS;
 
+	file_update_time(file);
+
 	ret = 0;
 	if (bb->vm_ops->page_mkwrite)
 		ret = bb->vm_ops->page_mkwrite(vma, vmf);

If the filesystem's page_mkwrite() function is responsible for updating the time, can't the call to file_update_time() here be conditional?

Quoted 6 lines

I.e:

	ret = 0;
	if (bb->vm_ops->page_mkwrite)
 		ret = bb->vm_ops->page_mkwrite(vma, vmf);
	else
		file_update_time(file);

Hmm, I didn't look previously where do we get bb->vm_ops. It seems they
are inherited from vma->vm_ops so what you suggest should be safe without any further changes. So I can do that if someone who understands the sysfs code likes it more.

Honza

Signature · 9 lines
Jan Kara <[email protected]>
SUSE Labs, CR

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#11 lore raw

Re: [PATCH 04/11] ceph: Push file_update_time() into ceph_page_mkwrite()

In reply to Alex Elder
Quoted 10 lines · Alex Elder
Quoted 3 lines · Jan Kara

This will update the timestamp even if a write
fault fails, which is different from before.

Hard to avoid though.

Yes. Relatively easy solution for this (at least for some filesystems)
is to include time update into other operations filesystem is doing. Usually filesystem can do some preparations, then take page lock and then update time stamps together with other things it wants to do. It usually will be even faster than current scheme. But I decided to leave that to fs maintainers because page_mkwrite() code tends to be tricky wrt locking etc.

Quoted 3 lines

Looks good to me.

Thanks.

Honza

Quoted 20 lines
Quoted 17 lines
 fs/ceph/addr.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/ceph/addr.c +3 -0
index 173b1d2..12b139f 100644
@@ -1181,6 +1181,9 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	loff_t size, len;
 	int ret;
 
+	/* Update time before taking page lock */
+	file_update_time(vma->vm_file);
+
 	size = i_size_read(inode);
 	if (off + PAGE_CACHE_SIZE <= size)
 		len = PAGE_CACHE_SIZE;
Signature · 9 lines
Jan Kara <[email protected]>
SUSE Labs, CR

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#24 lore raw

Re: [PATCH 10/11] nfs: Push file_update_time() into nfs_vm_page_mkwrite()

In reply to Myklebust, Trond
Quoted 25 lines · Trond
Quoted 12 lines · Jan Kara
---
 fs/nfs/file.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/nfs/file.c +0 -0
index c43a452..2407922 100644

fs/nfs/file.c static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 533

Quoted 9 lines
fs/nfs/file.c +3 -0
@@ -525,6 +525,9 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	/* make sure the cache has finished storing the page */
 	nfs_fscache_wait_on_page_write(NFS_I(dentry->d_inode), page);
 
+	/* Update file times before taking page lock */
+	file_update_time(filp);
+
 	lock_page(page);
 	mapping = page->mapping;
 	if (mapping != dentry->d_inode->i_mapping)

Hi Jan,

Quoted 2 lines

file_update_time() is a no-op in NFS, since we set S_NOATIME|S_NOCMTIME on all inodes.

Thanks. I've discarded the patch.

Honza

Signature · 6 lines
Jan Kara <[email protected]>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author reviewer
#3 lore raw

Re: [PATCH 01/11] perf: Push file_update_time() into perf_mmap_fault()

In reply to Peter Zijlstra
Quoted 29 lines · Peter Zijlstra
Quoted 14 lines · Jan Kara
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
CC Paul Mackerras <[email protected]>
CC Arnaldo Carvalho de Melo <[email protected]>
---
 kernel/events/core.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
kernel/events/core.c +0 -0
index ba36013..61a67f3 100644

kernel/events/core.c static int perf_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) · line 3324

Quoted 10 lines
kernel/events/core.c +3 -1
@@ -3316,8 +3316,10 @@ static int perf_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	int ret = VM_FAULT_SIGBUS;
 
 	if (vmf->flags & FAULT_FLAG_MKWRITE) {
-		if (vmf->pgoff == 0)
+		if (vmf->pgoff == 0) {
 			ret = 0;
+			file_update_time(vma->vm_file);
+		}
 		return ret;
 	}

Its an anon filedesc, there's no actual file and while I guess one could probably call fstat() on it, people really shouldn't care.

Quoted 1 line

So feel free to introduce this patch to the bitbucket.

Thanks for letting me know. Patch removed.

Honza

Signature · 9 lines
Jan Kara <[email protected]>
SUSE Labs, CR

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#9 lore raw

Re: [PATCH 04/11] ceph: Push file_update_time() into ceph_page_mkwrite()

In reply to Sage Weil
Quoted 10 lines · Sage Weil
Quoted 9 lines · Alex Elder
Quoted 3 lines · Jan Kara

This will update the timestamp even if a write
fault fails, which is different from before.

Quoted 8 lines
Quoted 3 lines

Hard to avoid though.

Looks good to me.

Yeah. Let's put something in the tracker to take a look later (I think we can do better), but this is okay for now.

Thanks! Just an administrative note - the tag above should rather be
Acked-by or Reviewed-by. You'd use Signed-off-by only if you took the patch and merged it via your tree... So can I add Acked-by?

Honza

Quoted 28 lines
Quoted 28 lines
Quoted 8 lines
 fs/ceph/addr.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/ceph/addr.c +0 -0
index 173b1d2..12b139f 100644

fs/ceph/addr.c static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 1189

Quoted 9 lines
fs/ceph/addr.c +3 -0
@@ -1181,6 +1181,9 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	loff_t size, len;
 	int ret;
 
+	/* Update time before taking page lock */
+	file_update_time(vma->vm_file);
+
 	size = i_size_read(inode);
 	if (off + PAGE_CACHE_SIZE <= size)
 		len = PAGE_CACHE_SIZE;

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 9 lines
Jan Kara <[email protected]>
SUSE Labs, CR

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#10 lore raw

Re: [PATCH 04/11] ceph: Push file_update_time() into ceph_page_mkwrite()

Quoted 15 lines · Jan Kara
Quoted 14 lines · Sage Weil
Quoted 12 lines · Alex Elder
Quoted 3 lines · Jan Kara

This will update the timestamp even if a write
fault fails, which is different from before.

Hard to avoid though.

Looks good to me.

Quoted 7 lines
Quoted 4 lines

Yeah. Let's put something in the tracker to take a look later (I think we can do better), but this is okay for now.

Thanks! Just an administrative note - the tag above should rather be
Acked-by or Reviewed-by. You'd use Signed-off-by only if you took the patch and merged it via your tree... So can I add Acked-by?

Oh, right. Acked-by!

sage

Quoted 40 lines

Honza

Quoted 28 lines
Quoted 28 lines
Quoted 8 lines
 fs/ceph/addr.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/ceph/addr.c +0 -0
index 173b1d2..12b139f 100644

fs/ceph/addr.c static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 1189

Quoted 9 lines
fs/ceph/addr.c +3 -0
@@ -1181,6 +1181,9 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	loff_t size, len;
 	int ret;
 
+	/* Update time before taking page lock */
+	file_update_time(vma->vm_file);
+
 	size = i_size_read(inode);
 	if (off + PAGE_CACHE_SIZE <= size)
 		len = PAGE_CACHE_SIZE;

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 6 lines
Jan Kara <[email protected]>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#21 lore raw

Re: [PATCH 09/11] sysfs: Push file_update_time() into bin_page_mkwrite()

In reply to Jan Kara
Quoted 32 lines · Jan Kara
Quoted 25 lines · Alex Elder
Quoted 11 lines · Jan Kara
CC Greg Kroah-Hartman <[email protected]>
---
 fs/sysfs/bin.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/sysfs/bin.c +0 -0
index a475983..6ceb16f 100644

fs/sysfs/bin.c static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 232

Quoted 8 lines
fs/sysfs/bin.c +2 -0
@@ -225,6 +225,8 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	if (!sysfs_get_active(attr_sd))
 		return VM_FAULT_SIGBUS;
 
+	file_update_time(file);
+
 	ret = 0;
 	if (bb->vm_ops->page_mkwrite)
 		ret = bb->vm_ops->page_mkwrite(vma, vmf);

If the filesystem's page_mkwrite() function is responsible for updating the time, can't the call to file_update_time() here be conditional?

Quoted 6 lines

I.e:

	ret = 0;
	if (bb->vm_ops->page_mkwrite)
 		ret = bb->vm_ops->page_mkwrite(vma, vmf);
	else
		file_update_time(file);
Quoted 4 lines

Hmm, I didn't look previously where do we get bb->vm_ops. It seems they
are inherited from vma->vm_ops so what you suggest should be safe without any further changes. So I can do that if someone who understands the sysfs code likes it more.

I do. Essentially sysfs is being a stackable filesystem here, because sysfs needs the ability to remove a file mapping.

In practice we could probably get away without a single file_update_time(file) here because there are mmio mappings. Normally for pci resources, but we might as well use good form since we can.

Eric

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>