All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] procfs: stop using vmtruncate
Date: Mon, 20 Jun 2011 18:47:27 -0400	[thread overview]
Message-ID: <20110620224727.GA22187@infradead.org> (raw)

Procfs doens't have any ->truncate instances, so all vmtruncate calls can
be replaced with truncate_setsize, given that we've just done the
inode_newsize_ok check as part of inode_change_ok just before.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/fs/proc/base.c
===================================================================
--- linux-2.6.orig/fs/proc/base.c	2011-06-10 11:51:06.203880498 +0200
+++ linux-2.6/fs/proc/base.c	2011-06-21 00:39:37.454049407 +0200
@@ -615,12 +615,8 @@ int proc_setattr(struct dentry *dentry,
 	if (error)
 		return error;
 
-	if ((attr->ia_valid & ATTR_SIZE) &&
-	    attr->ia_size != i_size_read(inode)) {
-		error = vmtruncate(inode, attr->ia_size);
-		if (error)
-			return error;
-	}
+	if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size != i_size_read(inode))
+		truncate_setsize(inode, attr->ia_size);
 
 	setattr_copy(inode, attr);
 	mark_inode_dirty(inode);
Index: linux-2.6/fs/proc/generic.c
===================================================================
--- linux-2.6.orig/fs/proc/generic.c	2011-06-10 11:51:06.203880498 +0200
+++ linux-2.6/fs/proc/generic.c	2011-06-21 00:39:27.764049898 +0200
@@ -251,7 +251,7 @@ static const struct file_operations proc
 	.write		= proc_file_write,
 };
 
-static int proc_notify_change(struct dentry *dentry, struct iattr *iattr)
+static int proc_file_setattr(struct dentry *dentry, struct iattr *iattr)
 {
 	struct inode *inode = dentry->d_inode;
 	struct proc_dir_entry *de = PDE(inode);
@@ -262,11 +262,8 @@ static int proc_notify_change(struct den
 		return error;
 
 	if ((iattr->ia_valid & ATTR_SIZE) &&
-	    iattr->ia_size != i_size_read(inode)) {
-		error = vmtruncate(inode, iattr->ia_size);
-		if (error)
-			return error;
-	}
+	    iattr->ia_size != i_size_read(inode))
+		truncate_setsize(inode, iattr->ia_size);
 
 	setattr_copy(inode, iattr);
 	mark_inode_dirty(inode);
@@ -290,7 +287,7 @@ static int proc_getattr(struct vfsmount
 }
 
 static const struct inode_operations proc_file_inode_operations = {
-	.setattr	= proc_notify_change,
+	.setattr	= proc_file_setattr,
 };
 
 /*
@@ -549,7 +546,7 @@ static const struct file_operations proc
 static const struct inode_operations proc_dir_inode_operations = {
 	.lookup		= proc_lookup,
 	.getattr	= proc_getattr,
-	.setattr	= proc_notify_change,
+	.setattr	= proc_file_setattr,
 };
 
 static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp)
Index: linux-2.6/fs/proc/proc_sysctl.c
===================================================================
--- linux-2.6.orig/fs/proc/proc_sysctl.c	2011-06-10 11:51:06.203880498 +0200
+++ linux-2.6/fs/proc/proc_sysctl.c	2011-06-21 00:39:45.980715641 +0200
@@ -337,12 +337,8 @@ static int proc_sys_setattr(struct dentr
 	if (error)
 		return error;
 
-	if ((attr->ia_valid & ATTR_SIZE) &&
-	    attr->ia_size != i_size_read(inode)) {
-		error = vmtruncate(inode, attr->ia_size);
-		if (error)
-			return error;
-	}
+	if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size != i_size_read(inode))
+		truncate_setsize(inode, attr->ia_size);
 
 	setattr_copy(inode, attr);
 	mark_inode_dirty(inode);

             reply	other threads:[~2011-06-20 22:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-20 22:47 Christoph Hellwig [this message]
2011-06-21  2:05 ` [PATCH] procfs: stop using vmtruncate Al Viro
2011-06-21  7:43   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110620224727.GA22187@infradead.org \
    --to=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.