linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 12/13] kill free_page_put_link()
Date: Fri,  1 Jan 2016 06:38:20 +0000	[thread overview]
Message-ID: <1451630301-30618-12-git-send-email-viro@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20160101063624.GG9938@ZenIV.linux.org.uk>

From: Al Viro <viro@zeniv.linux.org.uk>

all callers are better off with kfree_put_link()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/configfs/symlink.c | 12 ++++++------
 fs/fuse/dir.c         |  6 +++---
 fs/kernfs/symlink.c   | 12 ++++++------
 fs/libfs.c            |  6 ------
 include/linux/fs.h    |  1 -
 5 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c
index b91c01e..e9de962 100644
--- a/fs/configfs/symlink.c
+++ b/fs/configfs/symlink.c
@@ -282,29 +282,29 @@ static int configfs_getlink(struct dentry *dentry, char * path)
 static const char *configfs_get_link(struct dentry *dentry,
 				     struct inode *inode, void **cookie)
 {
-	unsigned long page;
+	char *page;
 	int error;
 
 	if (!dentry)
 		return ERR_PTR(-ECHILD);
 
-	page = get_zeroed_page(GFP_KERNEL);
+	page = kzalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!page)
 		return ERR_PTR(-ENOMEM);
 
-	error = configfs_getlink(dentry, (char *)page);
+	error = configfs_getlink(dentry, page);
 	if (!error) {
-		return *cookie = (void *)page;
+		return *cookie = page;
 	}
 
-	free_page(page);
+	kfree(page);
 	return ERR_PTR(error);
 }
 
 const struct inode_operations configfs_symlink_inode_operations = {
 	.get_link = configfs_get_link,
 	.readlink = generic_readlink,
-	.put_link = free_page_put_link,
+	.put_link = kfree_put_link,
 	.setattr = configfs_setattr,
 };
 
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 148e8ef..def0a4d 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1376,7 +1376,7 @@ static const char *fuse_get_link(struct dentry *dentry,
 	if (!dentry)
 		return ERR_PTR(-ECHILD);
 
-	link = (char *) __get_free_page(GFP_KERNEL);
+	link = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!link)
 		return ERR_PTR(-ENOMEM);
 
@@ -1388,7 +1388,7 @@ static const char *fuse_get_link(struct dentry *dentry,
 	args.out.args[0].value = link;
 	ret = fuse_simple_request(fc, &args);
 	if (ret < 0) {
-		free_page((unsigned long) link);
+		kfree(link);
 		link = ERR_PTR(ret);
 	} else {
 		link[ret] = '\0';
@@ -1913,7 +1913,7 @@ static const struct inode_operations fuse_common_inode_operations = {
 static const struct inode_operations fuse_symlink_inode_operations = {
 	.setattr	= fuse_setattr,
 	.get_link	= fuse_get_link,
-	.put_link	= free_page_put_link,
+	.put_link	= kfree_put_link,
 	.readlink	= generic_readlink,
 	.getattr	= fuse_getattr,
 	.setxattr	= fuse_setxattr,
diff --git a/fs/kernfs/symlink.c b/fs/kernfs/symlink.c
index ffae857..f9efdae 100644
--- a/fs/kernfs/symlink.c
+++ b/fs/kernfs/symlink.c
@@ -116,19 +116,19 @@ static const char *kernfs_iop_get_link(struct dentry *dentry,
 				       struct inode *inode, void **cookie)
 {
 	int error = -ENOMEM;
-	unsigned long page;
+	char *page;
 
 	if (!dentry)
 		return ERR_PTR(-ECHILD);
-	page = get_zeroed_page(GFP_KERNEL);
+	page = kzalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!page)
 		return ERR_PTR(-ENOMEM);
-	error = kernfs_getlink(dentry, (char *)page);
+	error = kernfs_getlink(dentry, page);
 	if (unlikely(error < 0)) {
-		free_page((unsigned long)page);
+		kfree(page);
 		return ERR_PTR(error);
 	}
-	return *cookie = (char *)page;
+	return *cookie = page;
 }
 
 const struct inode_operations kernfs_symlink_iops = {
@@ -138,7 +138,7 @@ const struct inode_operations kernfs_symlink_iops = {
 	.listxattr	= kernfs_iop_listxattr,
 	.readlink	= generic_readlink,
 	.get_link	= kernfs_iop_get_link,
-	.put_link	= free_page_put_link,
+	.put_link	= kfree_put_link,
 	.setattr	= kernfs_iop_setattr,
 	.getattr	= kernfs_iop_getattr,
 	.permission	= kernfs_iop_permission,
diff --git a/fs/libfs.c b/fs/libfs.c
index 8dc37fc..fec7ab0 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1025,12 +1025,6 @@ void kfree_put_link(struct inode *unused, void *cookie)
 }
 EXPORT_SYMBOL(kfree_put_link);
 
-void free_page_put_link(struct inode *unused, void *cookie)
-{
-	free_page((unsigned long) cookie);
-}
-EXPORT_SYMBOL(free_page_put_link);
-
 /*
  * nop .set_page_dirty method so that people can use .page_mkwrite on
  * anon inodes.
diff --git a/include/linux/fs.h b/include/linux/fs.h
index d2fdf09..138e206 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2743,7 +2743,6 @@ extern int __page_symlink(struct inode *inode, const char *symname, int len,
 extern int page_symlink(struct inode *inode, const char *symname, int len);
 extern const struct inode_operations page_symlink_inode_operations;
 extern void kfree_put_link(struct inode *, void *);
-extern void free_page_put_link(struct inode *, void *);
 extern int generic_readlink(struct dentry *, char __user *, int);
 extern void generic_fillattr(struct inode *, struct kstat *);
 int vfs_getattr_nosec(struct path *path, struct kstat *stat);
-- 
2.1.4


  parent reply	other threads:[~2016-01-01  6:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-01  6:36 [RFC] ->get_link(), ->put_link() and cookies Al Viro
2016-01-01  6:38 ` [PATCH 01/13] switch befs long symlinks to page_symlink_operations Al Viro
2016-01-01  6:38 ` [PATCH 02/13] logfs: don't duplicate page_symlink_inode_operations Al Viro
2016-01-01  6:38 ` [PATCH 03/13] udf: " Al Viro
2016-01-05 16:27   ` Jan Kara
2016-01-01  6:38 ` [PATCH 04/13] ufs: get rid of ->setattr() for symlinks Al Viro
2016-01-01  6:38 ` [PATCH 05/13] namei: page_getlink() and page_follow_link_light() are the same thing Al Viro
2016-01-01  6:38 ` [PATCH 06/13] don't put symlink bodies in pagecache into highmem Al Viro
2016-01-01  6:38 ` [PATCH 07/13] replace ->follow_link() with new method that could stay in RCU mode Al Viro
2016-01-01  6:38 ` [PATCH 08/13] teach page_get_link() to work " Al Viro
2016-01-01  6:38 ` [PATCH 09/13] teach shmem_get_link() " Al Viro
2016-01-01  6:38 ` [PATCH 10/13] teach proc_self_get_link()/proc_thread_self_get_link() " Al Viro
2016-01-01  6:38 ` [PATCH 11/13] teach nfs_get_link() " Al Viro
2016-01-01  6:38 ` Al Viro [this message]
2016-01-01  6:38 ` [PATCH 13/13] switch ->get_link() to delayed_call, kill ->put_link() Al Viro
2016-01-03 19:53 ` [RFC] ->get_link(), ->put_link() and cookies Linus Torvalds
2016-01-03 20:21   ` Al Viro
2016-01-03 20:41     ` Linus Torvalds
2016-01-03 21:40       ` Al Viro

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=1451630301-30618-12-git-send-email-viro@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).