Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1299835 > unrolled thread

[RFC] ->get_link(), ->put_link() and cookies

Started byAl Viro <viro@ZenIV.linux.org.uk>
First post2016-01-01 07:40 +0100
Last post2016-01-03 22:50 +0100
Articles 17 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [RFC] ->get_link(), ->put_link() and cookies Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:40 +0100
    [PATCH 02/13] logfs: don't duplicate page_symlink_inode_operations Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:40 +0100
    [PATCH 11/13] teach nfs_get_link() to work in RCU mode Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:40 +0100
    [PATCH 03/13] udf: don't duplicate page_symlink_inode_operations Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:40 +0100
      Re: [PATCH 03/13] udf: don't duplicate page_symlink_inode_operations Jan Kara <jack@suse.cz> - 2016-01-05 17:30 +0100
    [PATCH 01/13] switch befs long symlinks to page_symlink_operations Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:40 +0100
    [PATCH 09/13] teach shmem_get_link() to work in RCU mode Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:40 +0100
    [PATCH 06/13] don't put symlink bodies in pagecache into highmem Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:40 +0100
    [PATCH 12/13] kill free_page_put_link() Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:50 +0100
    [PATCH 05/13] namei: page_getlink() and page_follow_link_light() are the same thing Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:50 +0100
    [PATCH 10/13] teach proc_self_get_link()/proc_thread_self_get_link() to work in RCU mode Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:50 +0100
    [PATCH 08/13] teach page_get_link() to work in RCU mode Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:50 +0100
    [PATCH 04/13] ufs: get rid of ->setattr() for symlinks Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-01 07:50 +0100
    Re: [RFC] ->get_link(), ->put_link() and cookies Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-03 21:00 +0100
      Re: [RFC] ->get_link(), ->put_link() and cookies Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-03 21:30 +0100
        Re: [RFC] ->get_link(), ->put_link() and cookies Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-03 21:50 +0100
          Re: [RFC] ->get_link(), ->put_link() and cookies Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-03 22:50 +0100

#1299835 — [RFC] ->get_link(), ->put_link() and cookies

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:40 +0100
Subject[RFC] ->get_link(), ->put_link() and cookies
Message-ID<qM1xv-6DT-1@gated-at.bofh.it>
	In cases when we need to pin the symlink body in some manner, we
need to undo whatever we'd done once the caller is done with the body.
That went through several variants, the latest (in -next right now) being
"have non-NULL ->put_link() and leave an argument for it in void *cookie,
address of which is passed to ->get_link()".

	Linus suggested getting rid of the cookie thing by deriving it
from the address of symlink body.  That breaks in some cases, though -
procfs and lustre, to name a couple.  Symlink body may be not enough.
Moreover, inode argument of ->put_link() is never used.

	AFAICS, the following ends up a lot cleaner:

1) struct delayed_call {
	void (*fn)(void *);
	void *arg;
} is defined.  Primitives:
	DEFINE_DELAYED_CALL(name)	- similar to DEFINE_MUTEX, et.al.
	set_delayed_call(p, fn, arg)	- sets fn and arg
	do_delayed_call(p)		- if fn is set, calls fn(arg)
	clear_delayed_call(p)		- clears fn

2) in struct saved replace void *cookie; with struct delayed_call done;
pass its address to ->get_link() and when/if it needs something to release
the body, let it do set_delayed_call(done, fn, arg).

3) remove ->put_link entirely

4) get rid of allocations in overlayfs ->get_link() - just let the ->get_link()
of underlying fs arrange the call it needs done and that's it; we don't need
to keep a reference to inode of underlying symlink around, which removes the
reason to allocate anything in there.

5) compensation of stack footprint changes: struct saved ->inode had been used
for two things - storing the inode between the pick_link() and get_link() and
keeping it until we decide to call its ->put_link().  Since the latter is gone
now, we don't need to store that thing in nd->stack[...] - we can move it to
nd->link_inode and be done with that.  That compensates the increase of
struct saved size, so we are only left with one extra word per
struct nameidata instance.

The reasons why I like it more than the variant proposed by Linus:
	* it allows to avoid convolutions in things like procfs and lustre
->get_link() instances; sure, we could stash a reference to the structure
we'll need somewhere near the symlink body, use container_of(), etc., but
it's a lot more convoluted
	* it doesn't need to keep an inode reference around, only for the
purpose of locating ->put_link().  Seeing that ->put_link() instances do not
give a damn about the inode, that's rather pointless (note, BTW, that all
we are promised in RCU mode is that memory of this struct inode hadn't been
reused yet).

I'd done that on top of vfs.git#work.symlinks; it's pretty much the same
as incremental I'd posted three weeks ago, except for the switch of three
instances from get_free_page/free_page_link to kmalloc/kfree_link.

It's in vfs.git#proposed.symlinks.  It survives the local beating.  Please,
review and comment.

Shortlog:
Al Viro (13):
      switch befs long symlinks to page_symlink_operations
      logfs: don't duplicate page_symlink_inode_operations
      udf: don't duplicate page_symlink_inode_operations
      ufs: get rid of ->setattr() for symlinks
      namei: page_getlink() and page_follow_link_light() are the same thing
      don't put symlink bodies in pagecache into highmem
      replace ->follow_link() with new method that could stay in RCU mode
      teach page_get_link() to work in RCU mode
      teach shmem_get_link() to work in RCU mode
      teach proc_self_get_link()/proc_thread_self_get_link() to work in RCU mode
      teach nfs_get_link() to work in RCU mode
      kill free_page_put_link()
      switch ->get_link() to delayed_call, kill ->put_link()

Diffstat:
 Documentation/filesystems/Locking             |   6 +-
 Documentation/filesystems/porting             |  17 ++++
 Documentation/filesystems/vfs.txt             |  21 ++---
 drivers/staging/lustre/lustre/llite/symlink.c |  24 ++---
 fs/9p/vfs_inode.c                             |  24 +++--
 fs/9p/vfs_inode_dotl.c                        |  21 +++--
 fs/affs/inode.c                               |   1 +
 fs/affs/namei.c                               |   1 +
 fs/affs/symlink.c                             |   9 +-
 fs/afs/inode.c                                |   1 +
 fs/autofs4/symlink.c                          |  14 ++-
 fs/befs/linuxvfs.c                            |  40 ++++----
 fs/btrfs/inode.c                              |   5 +-
 fs/ceph/inode.c                               |   2 +-
 fs/cifs/cifsfs.c                              |   3 +-
 fs/cifs/cifsfs.h                              |   5 +-
 fs/cifs/link.c                                |  10 +-
 fs/coda/cnode.c                               |   5 +-
 fs/coda/symlink.c                             |   4 +-
 fs/configfs/symlink.c                         |  22 +++--
 fs/cramfs/inode.c                             |   1 +
 fs/dcache.c                                   |   2 +-
 fs/ecryptfs/inode.c                           |  17 +++-
 fs/efs/inode.c                                |   1 +
 fs/efs/symlink.c                              |   4 +-
 fs/exofs/inode.c                              |   1 +
 fs/exofs/namei.c                              |   1 +
 fs/ext2/inode.c                               |   1 +
 fs/ext2/namei.c                               |   1 +
 fs/ext2/symlink.c                             |   5 +-
 fs/ext4/inode.c                               |   1 +
 fs/ext4/namei.c                               |   1 +
 fs/ext4/symlink.c                             |  29 +++---
 fs/f2fs/inode.c                               |   1 +
 fs/f2fs/namei.c                               |  31 ++++---
 fs/freevxfs/vxfs_inode.c                      |   1 +
 fs/fuse/dir.c                                 |  17 ++--
 fs/gfs2/inode.c                               |  19 ++--
 fs/hfsplus/inode.c                            |   2 +
 fs/hostfs/hostfs_kern.c                       |  22 ++---
 fs/hpfs/inode.c                               |   1 +
 fs/hpfs/namei.c                               |   5 +-
 fs/hugetlbfs/inode.c                          |   1 +
 fs/inode.c                                    |   6 ++
 fs/isofs/inode.c                              |   1 +
 fs/isofs/rock.c                               |   4 +-
 fs/jffs2/symlink.c                            |   2 +-
 fs/jfs/inode.c                                |   1 +
 fs/jfs/namei.c                                |   1 +
 fs/jfs/symlink.c                              |   5 +-
 fs/kernfs/symlink.c                           |  24 +++--
 fs/libfs.c                                    |  22 ++---
 fs/logfs/dir.c                                |   9 +-
 fs/logfs/inode.c                              |   3 +-
 fs/logfs/logfs.h                              |   1 -
 fs/minix/inode.c                              |   4 +-
 fs/namei.c                                    | 126 +++++++++++++-------------
 fs/ncpfs/inode.c                              |   4 +-
 fs/nfs/inode.c                                |  26 +++++-
 fs/nfs/symlink.c                              |  39 +++++---
 fs/nilfs2/inode.c                             |   1 +
 fs/nilfs2/namei.c                             |   4 +-
 fs/ocfs2/inode.c                              |   1 +
 fs/ocfs2/namei.c                              |   1 +
 fs/ocfs2/symlink.c                            |   3 +-
 fs/overlayfs/inode.c                          |  53 ++---------
 fs/proc/base.c                                |  24 +++--
 fs/proc/inode.c                               |  21 +++--
 fs/proc/namespaces.c                          |  10 +-
 fs/proc/self.c                                |  18 ++--
 fs/proc/thread_self.c                         |  19 ++--
 fs/qnx4/inode.c                               |   1 +
 fs/qnx6/inode.c                               |   1 +
 fs/ramfs/inode.c                              |   1 +
 fs/reiserfs/inode.c                           |   1 +
 fs/reiserfs/namei.c                           |   4 +-
 fs/romfs/super.c                              |   1 +
 fs/squashfs/inode.c                           |   2 +
 fs/squashfs/symlink.c                         |   3 +-
 fs/sysv/inode.c                               |   4 +-
 fs/ubifs/file.c                               |   2 +-
 fs/udf/inode.c                                |   3 +-
 fs/udf/namei.c                                |   8 +-
 fs/udf/symlink.c                              |   4 +-
 fs/udf/udfdecl.h                              |   1 -
 fs/ufs/Makefile                               |   2 +-
 fs/ufs/inode.c                                |   5 +-
 fs/ufs/namei.c                                |   5 +-
 fs/ufs/symlink.c                              |  42 ---------
 fs/ufs/ufs.h                                  |   4 -
 fs/xfs/xfs_iops.c                             |  14 ++-
 include/linux/delayed_call.h                  |  34 +++++++
 include/linux/fs.h                            |  16 ++--
 include/linux/nfs_fs.h                        |   1 +
 mm/shmem.c                                    |  48 ++++++----
 95 files changed, 570 insertions(+), 470 deletions(-)
 delete mode 100644 fs/ufs/symlink.c
 create mode 100644 include/linux/delayed_call.h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1299836 — [PATCH 02/13] logfs: don't duplicate page_symlink_inode_operations

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:40 +0100
Subject[PATCH 02/13] logfs: don't duplicate page_symlink_inode_operations
Message-ID<qM1xw-6DT-3@gated-at.bofh.it>
In reply to#1299835
From: Al Viro <viro@zeniv.linux.org.uk>

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/logfs/dir.c   | 8 +-------
 fs/logfs/inode.c | 2 +-
 fs/logfs/logfs.h | 1 -
 3 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index f9b45d4..99944a4 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -528,7 +528,7 @@ static int logfs_symlink(struct inode *dir, struct dentry *dentry,
 	if (IS_ERR(inode))
 		return PTR_ERR(inode);
 
-	inode->i_op = &logfs_symlink_iops;
+	inode->i_op = &page_symlink_inode_operations;
 	inode->i_mapping->a_ops = &logfs_reg_aops;
 
 	return __logfs_create(dir, dentry, inode, target, destlen);
@@ -776,12 +776,6 @@ fail:
 	return -EIO;
 }
 
-const struct inode_operations logfs_symlink_iops = {
-	.readlink	= generic_readlink,
-	.follow_link	= page_follow_link_light,
-	.put_link	= page_put_link,
-};
-
 const struct inode_operations logfs_dir_iops = {
 	.create		= logfs_create,
 	.link		= logfs_link,
diff --git a/fs/logfs/inode.c b/fs/logfs/inode.c
index af49e2d..06baa92 100644
--- a/fs/logfs/inode.c
+++ b/fs/logfs/inode.c
@@ -64,7 +64,7 @@ static void logfs_inode_setops(struct inode *inode)
 		inode->i_mapping->a_ops = &logfs_reg_aops;
 		break;
 	case S_IFLNK:
-		inode->i_op = &logfs_symlink_iops;
+		inode->i_op = &page_symlink_inode_operations;
 		inode->i_mapping->a_ops = &logfs_reg_aops;
 		break;
 	case S_IFSOCK:	/* fall through */
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h
index 5f09376..209a26d 100644
--- a/fs/logfs/logfs.h
+++ b/fs/logfs/logfs.h
@@ -495,7 +495,6 @@ static inline int logfs_get_sb_mtd(struct logfs_super *s, int mtdnr)
 #endif
 
 /* dir.c */
-extern const struct inode_operations logfs_symlink_iops;
 extern const struct inode_operations logfs_dir_iops;
 extern const struct file_operations logfs_dir_fops;
 int logfs_replay_journal(struct super_block *sb);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299837 — [PATCH 11/13] teach nfs_get_link() to work in RCU mode

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:40 +0100
Subject[PATCH 11/13] teach nfs_get_link() to work in RCU mode
Message-ID<qM1xw-6DT-15@gated-at.bofh.it>
In reply to#1299835
From: Al Viro <viro@zeniv.linux.org.uk>

based upon the corresponding patch from Neil's March patchset,
again with kmap-related horrors removed.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/nfs/inode.c         | 21 +++++++++++++++++++++
 fs/nfs/symlink.c       | 30 ++++++++++++++++++++----------
 include/linux/nfs_fs.h |  1 +
 3 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index ae9aa0b..aa828e8 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1087,6 +1087,27 @@ static bool nfs_mapping_need_revalidate_inode(struct inode *inode)
 		|| NFS_STALE(inode);
 }
 
+int nfs_revalidate_mapping_rcu(struct inode *inode)
+{
+	struct nfs_inode *nfsi = NFS_I(inode);
+	unsigned long *bitlock = &nfsi->flags;
+	int ret = 0;
+
+	if (IS_SWAPFILE(inode))
+		goto out;
+	if (nfs_mapping_need_revalidate_inode(inode)) {
+		ret = -ECHILD;
+		goto out;
+	}
+	spin_lock(&inode->i_lock);
+	if (test_bit(NFS_INO_INVALIDATING, bitlock) ||
+	    (nfsi->cache_validity & NFS_INO_INVALID_DATA))
+		ret = -ECHILD;
+	spin_unlock(&inode->i_lock);
+out:
+	return ret;
+}
+
 /**
  * __nfs_revalidate_mapping - Revalidate the pagecache
  * @inode - pointer to host inode
diff --git a/fs/nfs/symlink.c b/fs/nfs/symlink.c
index 8ade8a8..95c69af 100644
--- a/fs/nfs/symlink.c
+++ b/fs/nfs/symlink.c
@@ -48,16 +48,26 @@ static const char *nfs_get_link(struct dentry *dentry,
 	struct page *page;
 	void *err;
 
-	if (!dentry)
-		return ERR_PTR(-ECHILD);
-
-	err = ERR_PTR(nfs_revalidate_mapping(inode, inode->i_mapping));
-	if (err)
-		return err;
-	page = read_cache_page(&inode->i_data, 0,
-				(filler_t *)nfs_symlink_filler, inode);
-	if (IS_ERR(page))
-		return ERR_CAST(page);
+	if (!dentry) {
+		err = ERR_PTR(nfs_revalidate_mapping_rcu(inode));
+		if (err)
+			return err;
+		page = find_get_page(inode->i_mapping, 0);
+		if (!page)
+			return ERR_PTR(-ECHILD);
+		if (!PageUptodate(page)) {
+			put_page(page);
+			return ERR_PTR(-ECHILD);
+		}
+	} else {
+		err = ERR_PTR(nfs_revalidate_mapping(inode, inode->i_mapping));
+		if (err)
+			return err;
+		page = read_cache_page(&inode->i_data, 0,
+					(filler_t *)nfs_symlink_filler, inode);
+		if (IS_ERR(page))
+			return ERR_CAST(page);
+	}
 	*cookie = page;
 	return page_address(page);
 }
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index c0e9614..37a3d29 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -359,6 +359,7 @@ extern int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode);
 extern int nfs_revalidate_inode_rcu(struct nfs_server *server, struct inode *inode);
 extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *);
 extern int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping);
+extern int nfs_revalidate_mapping_rcu(struct inode *inode);
 extern int nfs_revalidate_mapping_protected(struct inode *inode, struct address_space *mapping);
 extern int nfs_setattr(struct dentry *, struct iattr *);
 extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr, struct nfs_fattr *);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299838 — [PATCH 03/13] udf: don't duplicate page_symlink_inode_operations

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:40 +0100
Subject[PATCH 03/13] udf: don't duplicate page_symlink_inode_operations
Message-ID<qM1xw-6DT-17@gated-at.bofh.it>
In reply to#1299835
From: Al Viro <viro@zeniv.linux.org.uk>

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/udf/inode.c   | 2 +-
 fs/udf/namei.c   | 7 +------
 fs/udf/udfdecl.h | 1 -
 3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 8d0b3ad..8675c2b 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1540,7 +1540,7 @@ reread:
 		break;
 	case ICBTAG_FILE_TYPE_SYMLINK:
 		inode->i_data.a_ops = &udf_symlink_aops;
-		inode->i_op = &udf_symlink_inode_operations;
+		inode->i_op = &page_symlink_inode_operations;
 		inode->i_mode = S_IFLNK | S_IRWXUGO;
 		break;
 	case ICBTAG_FILE_TYPE_MAIN:
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index c97b5a8..d0e6de1 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -921,7 +921,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 	}
 
 	inode->i_data.a_ops = &udf_symlink_aops;
-	inode->i_op = &udf_symlink_inode_operations;
+	inode->i_op = &page_symlink_inode_operations;
 
 	if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
 		struct kernel_lb_addr eloc;
@@ -1344,8 +1344,3 @@ const struct inode_operations udf_dir_inode_operations = {
 	.rename				= udf_rename,
 	.tmpfile			= udf_tmpfile,
 };
-const struct inode_operations udf_symlink_inode_operations = {
-	.readlink	= generic_readlink,
-	.follow_link	= page_follow_link_light,
-	.put_link	= page_put_link,
-};
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 47bb3f5..ce169b4 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -85,7 +85,6 @@ extern const struct inode_operations udf_dir_inode_operations;
 extern const struct file_operations udf_dir_operations;
 extern const struct inode_operations udf_file_inode_operations;
 extern const struct file_operations udf_file_operations;
-extern const struct inode_operations udf_symlink_inode_operations;
 extern const struct address_space_operations udf_aops;
 extern const struct address_space_operations udf_adinicb_aops;
 extern const struct address_space_operations udf_symlink_aops;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1301678 — Re: [PATCH 03/13] udf: don't duplicate page_symlink_inode_operations

FromJan Kara <jack@suse.cz>
Date2016-01-05 17:30 +0100
SubjectRe: [PATCH 03/13] udf: don't duplicate page_symlink_inode_operations
Message-ID<qNCEH-5ih-39@gated-at.bofh.it>
In reply to#1299838
On Fri 01-01-16 06:38:11, Al Viro wrote:
> From: Al Viro <viro@zeniv.linux.org.uk>
> 
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Looks good. I guess it's more convenient for you to take this change
through your tree so:

Acked-by: Jan Kara <jack@suse.cz>

								Honza
> ---
>  fs/udf/inode.c   | 2 +-
>  fs/udf/namei.c   | 7 +------
>  fs/udf/udfdecl.h | 1 -
>  3 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/udf/inode.c b/fs/udf/inode.c
> index 8d0b3ad..8675c2b 100644
> --- a/fs/udf/inode.c
> +++ b/fs/udf/inode.c
> @@ -1540,7 +1540,7 @@ reread:
>  		break;
>  	case ICBTAG_FILE_TYPE_SYMLINK:
>  		inode->i_data.a_ops = &udf_symlink_aops;
> -		inode->i_op = &udf_symlink_inode_operations;
> +		inode->i_op = &page_symlink_inode_operations;
>  		inode->i_mode = S_IFLNK | S_IRWXUGO;
>  		break;
>  	case ICBTAG_FILE_TYPE_MAIN:
> diff --git a/fs/udf/namei.c b/fs/udf/namei.c
> index c97b5a8..d0e6de1 100644
> --- a/fs/udf/namei.c
> +++ b/fs/udf/namei.c
> @@ -921,7 +921,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
>  	}
>  
>  	inode->i_data.a_ops = &udf_symlink_aops;
> -	inode->i_op = &udf_symlink_inode_operations;
> +	inode->i_op = &page_symlink_inode_operations;
>  
>  	if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
>  		struct kernel_lb_addr eloc;
> @@ -1344,8 +1344,3 @@ const struct inode_operations udf_dir_inode_operations = {
>  	.rename				= udf_rename,
>  	.tmpfile			= udf_tmpfile,
>  };
> -const struct inode_operations udf_symlink_inode_operations = {
> -	.readlink	= generic_readlink,
> -	.follow_link	= page_follow_link_light,
> -	.put_link	= page_put_link,
> -};
> diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
> index 47bb3f5..ce169b4 100644
> --- a/fs/udf/udfdecl.h
> +++ b/fs/udf/udfdecl.h
> @@ -85,7 +85,6 @@ extern const struct inode_operations udf_dir_inode_operations;
>  extern const struct file_operations udf_dir_operations;
>  extern const struct inode_operations udf_file_inode_operations;
>  extern const struct file_operations udf_file_operations;
> -extern const struct inode_operations udf_symlink_inode_operations;
>  extern const struct address_space_operations udf_aops;
>  extern const struct address_space_operations udf_adinicb_aops;
>  extern const struct address_space_operations udf_symlink_aops;
> -- 
> 2.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299839 — [PATCH 01/13] switch befs long symlinks to page_symlink_operations

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:40 +0100
Subject[PATCH 01/13] switch befs long symlinks to page_symlink_operations
Message-ID<qM1xw-6DT-5@gated-at.bofh.it>
In reply to#1299835
From: Al Viro <viro@zeniv.linux.org.uk>

just give them the right ->readpage()...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/befs/linuxvfs.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 46aedac..1c8b0dc 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -42,7 +42,7 @@ static struct inode *befs_iget(struct super_block *, unsigned long);
 static struct inode *befs_alloc_inode(struct super_block *sb);
 static void befs_destroy_inode(struct inode *inode);
 static void befs_destroy_inodecache(void);
-static const char *befs_follow_link(struct dentry *, void **);
+static int befs_symlink_readpage(struct file *, struct page *);
 static int befs_utf2nls(struct super_block *sb, const char *in, int in_len,
 			char **out, int *out_len);
 static int befs_nls2utf(struct super_block *sb, const char *in, int in_len,
@@ -79,10 +79,8 @@ static const struct address_space_operations befs_aops = {
 	.bmap		= befs_bmap,
 };
 
-static const struct inode_operations befs_symlink_inode_operations = {
-	.readlink	= generic_readlink,
-	.follow_link	= befs_follow_link,
-	.put_link	= kfree_put_link,
+static const struct address_space_operations befs_symlink_aops = {
+	.readpage	= befs_symlink_readpage,
 };
 
 /* 
@@ -398,7 +396,8 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
 		inode->i_fop = &befs_dir_operations;
 	} else if (S_ISLNK(inode->i_mode)) {
 		if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
-			inode->i_op = &befs_symlink_inode_operations;
+			inode->i_op = &page_symlink_inode_operations;
+			inode->i_mapping->a_ops = &befs_symlink_aops;
 		} else {
 			inode->i_link = befs_ino->i_data.symlink;
 			inode->i_op = &simple_symlink_inode_operations;
@@ -463,31 +462,35 @@ befs_destroy_inodecache(void)
  * The data stream become link name. Unless the LONG_SYMLINK
  * flag is set.
  */
-static const char *
-befs_follow_link(struct dentry *dentry, void **cookie)
+static int befs_symlink_readpage(struct file *unused, struct page *page)
 {
-	struct super_block *sb = dentry->d_sb;
-	struct befs_inode_info *befs_ino = BEFS_I(d_inode(dentry));
+	struct inode *inode = page->mapping->host;
+	struct super_block *sb = inode->i_sb;
+	struct befs_inode_info *befs_ino = BEFS_I(inode);
 	befs_data_stream *data = &befs_ino->i_data.ds;
 	befs_off_t len = data->size;
-	char *link;
+	char *link = kmap(page);
 
-	if (len == 0) {
+	if (len == 0 || len > PAGE_SIZE) {
 		befs_error(sb, "Long symlink with illegal length");
-		return ERR_PTR(-EIO);
+		goto fail;
 	}
 	befs_debug(sb, "Follow long symlink");
 
-	link = kmalloc(len, GFP_NOFS);
-	if (!link)
-		return ERR_PTR(-ENOMEM);
 	if (befs_read_lsymlink(sb, data, link, len) != len) {
-		kfree(link);
 		befs_error(sb, "Failed to read entire long symlink");
-		return ERR_PTR(-EIO);
+		goto fail;
 	}
 	link[len - 1] = '\0';
-	return *cookie = link;
+	SetPageUptodate(page);
+	kunmap(page);
+	unlock_page(page);
+	return 0;
+fail:
+	SetPageError(page);
+	kunmap(page);
+	unlock_page(page);
+	return -EIO;
 }
 
 /*
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299840 — [PATCH 09/13] teach shmem_get_link() to work in RCU mode

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:40 +0100
Subject[PATCH 09/13] teach shmem_get_link() to work in RCU mode
Message-ID<qM1xw-6DT-13@gated-at.bofh.it>
In reply to#1299835
From: Al Viro <viro@zeniv.linux.org.uk>

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 mm/shmem.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 684dbc3..0605716 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2501,12 +2501,20 @@ static const char *shmem_get_link(struct dentry *dentry,
 {
 	struct page *page = NULL;
 	int error;
-	if (!dentry)
-		return ERR_PTR(-ECHILD);
-	error = shmem_getpage(inode, 0, &page, SGP_READ, NULL);
-	if (error)
-		return ERR_PTR(error);
-	unlock_page(page);
+	if (!dentry) {
+		page = find_get_page(inode->i_mapping, 0);
+		if (!page)
+			return ERR_PTR(-ECHILD);
+		if (!PageUptodate(page)) {
+			put_page(page);
+			return ERR_PTR(-ECHILD);
+		}
+	} else {
+		error = shmem_getpage(inode, 0, &page, SGP_READ, NULL);
+		if (error)
+			return ERR_PTR(error);
+		unlock_page(page);
+	}
 	*cookie = page;
 	return page_address(page);
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299841 — [PATCH 06/13] don't put symlink bodies in pagecache into highmem

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:40 +0100
Subject[PATCH 06/13] don't put symlink bodies in pagecache into highmem
Message-ID<qM1xw-6DT-9@gated-at.bofh.it>
In reply to#1299835
From: Al Viro <viro@zeniv.linux.org.uk>

kmap() in page_follow_link_light() needed to go - allowing to hold
an arbitrary number of kmaps for long is a great way to deadlocking
the system.

new helper (inode_nohighmem(inode)) needs to be used for pagecache
symlinks inodes; done for all in-tree cases.  page_follow_link_light()
instrumented to yell about anything missed.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 Documentation/filesystems/porting |  5 +++++
 fs/affs/inode.c                   |  1 +
 fs/affs/namei.c                   |  1 +
 fs/affs/symlink.c                 |  4 +---
 fs/afs/inode.c                    |  1 +
 fs/befs/linuxvfs.c                |  5 ++---
 fs/btrfs/inode.c                  |  2 ++
 fs/coda/cnode.c                   |  2 ++
 fs/coda/symlink.c                 |  4 +---
 fs/cramfs/inode.c                 |  1 +
 fs/efs/inode.c                    |  1 +
 fs/efs/symlink.c                  |  4 +---
 fs/exofs/inode.c                  |  1 +
 fs/exofs/namei.c                  |  1 +
 fs/ext2/inode.c                   |  1 +
 fs/ext2/namei.c                   |  1 +
 fs/ext4/inode.c                   |  1 +
 fs/ext4/namei.c                   |  1 +
 fs/ext4/symlink.c                 | 10 +++-------
 fs/f2fs/inode.c                   |  1 +
 fs/f2fs/namei.c                   |  5 ++---
 fs/freevxfs/vxfs_inode.c          |  1 +
 fs/hfsplus/inode.c                |  2 ++
 fs/hpfs/inode.c                   |  1 +
 fs/hpfs/namei.c                   |  5 ++---
 fs/hugetlbfs/inode.c              |  1 +
 fs/inode.c                        |  6 ++++++
 fs/isofs/inode.c                  |  1 +
 fs/isofs/rock.c                   |  4 +---
 fs/jfs/inode.c                    |  1 +
 fs/jfs/namei.c                    |  1 +
 fs/logfs/dir.c                    |  1 +
 fs/logfs/inode.c                  |  1 +
 fs/minix/inode.c                  |  1 +
 fs/namei.c                        |  9 +++------
 fs/ncpfs/inode.c                  |  1 +
 fs/nfs/inode.c                    |  5 +++--
 fs/nfs/symlink.c                  |  2 +-
 fs/nilfs2/inode.c                 |  1 +
 fs/nilfs2/namei.c                 |  1 +
 fs/ocfs2/inode.c                  |  1 +
 fs/ocfs2/namei.c                  |  1 +
 fs/qnx4/inode.c                   |  1 +
 fs/qnx6/inode.c                   |  1 +
 fs/ramfs/inode.c                  |  1 +
 fs/reiserfs/inode.c               |  1 +
 fs/reiserfs/namei.c               |  1 +
 fs/romfs/super.c                  |  1 +
 fs/squashfs/inode.c               |  2 ++
 fs/sysv/inode.c                   |  1 +
 fs/udf/inode.c                    |  1 +
 fs/udf/namei.c                    |  1 +
 fs/udf/symlink.c                  |  4 +---
 fs/ufs/inode.c                    |  1 +
 fs/ufs/namei.c                    |  1 +
 include/linux/fs.h                |  1 +
 mm/shmem.c                        |  9 +++------
 57 files changed, 81 insertions(+), 46 deletions(-)

diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting
index f24d1b8..3eb7c35 100644
--- a/Documentation/filesystems/porting
+++ b/Documentation/filesystems/porting
@@ -504,3 +504,8 @@ in your dentry operations instead.
 [mandatory]
 	__fd_install() & fd_install() can now sleep. Callers should not
 	hold a spinlock	or other resources that do not allow a schedule.
+--
+[mandatory]
+	any symlink that might use page_follow_link_light/page_put_link() must
+	have inode_nohighmem(inode) called before anything might start playing with
+	its pagecache.
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 1734950..0fdb0f5 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -140,6 +140,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
 		break;
 	case ST_SOFTLINK:
 		inode->i_mode |= S_IFLNK;
+		inode_nohighmem(inode);
 		inode->i_op = &affs_symlink_inode_operations;
 		inode->i_data.a_ops = &affs_symlink_aops;
 		break;
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 181e05b..00d3002 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -344,6 +344,7 @@ affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
 		return -ENOSPC;
 
 	inode->i_op = &affs_symlink_inode_operations;
+	inode_nohighmem(inode);
 	inode->i_data.a_ops = &affs_symlink_aops;
 	inode->i_mode = S_IFLNK | 0777;
 	mode_to_prot(inode);
diff --git a/fs/affs/symlink.c b/fs/affs/symlink.c
index ea5b69a..e3f9dc3 100644
--- a/fs/affs/symlink.c
+++ b/fs/affs/symlink.c
@@ -14,7 +14,7 @@ static int affs_symlink_readpage(struct file *file, struct page *page)
 {
 	struct buffer_head *bh;
 	struct inode *inode = page->mapping->host;
-	char *link = kmap(page);
+	char *link = page_address(page);
 	struct slink_front *lf;
 	int			 i, j;
 	char			 c;
@@ -57,12 +57,10 @@ static int affs_symlink_readpage(struct file *file, struct page *page)
 	link[i] = '\0';
 	affs_brelse(bh);
 	SetPageUptodate(page);
-	kunmap(page);
 	unlock_page(page);
 	return 0;
 fail:
 	SetPageError(page);
-	kunmap(page);
 	unlock_page(page);
 	return -EIO;
 }
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index e06f5a2..86cc726 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -56,6 +56,7 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key)
 	case AFS_FTYPE_SYMLINK:
 		inode->i_mode	= S_IFLNK | vnode->status.mode;
 		inode->i_op	= &page_symlink_inode_operations;
+		inode_nohighmem(inode);
 		break;
 	default:
 		printk("kAFS: AFS vnode with undefined type\n");
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 1c8b0dc..25250fa 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -397,6 +397,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
 	} else if (S_ISLNK(inode->i_mode)) {
 		if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
 			inode->i_op = &page_symlink_inode_operations;
+			inode_nohighmem(inode);
 			inode->i_mapping->a_ops = &befs_symlink_aops;
 		} else {
 			inode->i_link = befs_ino->i_data.symlink;
@@ -469,7 +470,7 @@ static int befs_symlink_readpage(struct file *unused, struct page *page)
 	struct befs_inode_info *befs_ino = BEFS_I(inode);
 	befs_data_stream *data = &befs_ino->i_data.ds;
 	befs_off_t len = data->size;
-	char *link = kmap(page);
+	char *link = page_address(page);
 
 	if (len == 0 || len > PAGE_SIZE) {
 		befs_error(sb, "Long symlink with illegal length");
@@ -483,12 +484,10 @@ static int befs_symlink_readpage(struct file *unused, struct page *page)
 	}
 	link[len - 1] = '\0';
 	SetPageUptodate(page);
-	kunmap(page);
 	unlock_page(page);
 	return 0;
 fail:
 	SetPageError(page);
-	kunmap(page);
 	unlock_page(page);
 	return -EIO;
 }
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a70c579..70f98bf 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3774,6 +3774,7 @@ cache_acl:
 		break;
 	case S_IFLNK:
 		inode->i_op = &btrfs_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &btrfs_symlink_aops;
 		break;
 	default:
@@ -9705,6 +9706,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
 	btrfs_free_path(path);
 
 	inode->i_op = &btrfs_symlink_inode_operations;
+	inode_nohighmem(inode);
 	inode->i_mapping->a_ops = &btrfs_symlink_aops;
 	inode_set_bytes(inode, name_len);
 	btrfs_i_size_write(inode, name_len);
diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c
index 7740b1c..dd6a79e 100644
--- a/fs/coda/cnode.c
+++ b/fs/coda/cnode.c
@@ -8,6 +8,7 @@
 
 #include <linux/coda.h>
 #include <linux/coda_psdev.h>
+#include <linux/pagemap.h>
 #include "coda_linux.h"
 
 static inline int coda_fideq(struct CodaFid *fid1, struct CodaFid *fid2)
@@ -35,6 +36,7 @@ static void coda_fill_inode(struct inode *inode, struct coda_vattr *attr)
                 inode->i_fop = &coda_dir_operations;
         } else if (S_ISLNK(inode->i_mode)) {
 		inode->i_op = &coda_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_data.a_ops = &coda_symlink_aops;
 		inode->i_mapping = &inode->i_data;
 	} else
diff --git a/fs/coda/symlink.c b/fs/coda/symlink.c
index ab94ef6..03736e2 100644
--- a/fs/coda/symlink.c
+++ b/fs/coda/symlink.c
@@ -26,7 +26,7 @@ static int coda_symlink_filler(struct file *file, struct page *page)
 	int error;
 	struct coda_inode_info *cii;
 	unsigned int len = PAGE_SIZE;
-	char *p = kmap(page);
+	char *p = page_address(page);
 
 	cii = ITOC(inode);
 
@@ -34,13 +34,11 @@ static int coda_symlink_filler(struct file *file, struct page *page)
 	if (error)
 		goto fail;
 	SetPageUptodate(page);
-	kunmap(page);
 	unlock_page(page);
 	return 0;
 
 fail:
 	SetPageError(page);
-	kunmap(page);
 	unlock_page(page);
 	return error;
 }
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 355c522..b862bc2 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -100,6 +100,7 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
 		break;
 	case S_IFLNK:
 		inode->i_op = &page_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_data.a_ops = &cramfs_aops;
 		break;
 	default:
diff --git a/fs/efs/inode.c b/fs/efs/inode.c
index 079d203..cdf0872 100644
--- a/fs/efs/inode.c
+++ b/fs/efs/inode.c
@@ -151,6 +151,7 @@ struct inode *efs_iget(struct super_block *super, unsigned long ino)
 			break;
 		case S_IFLNK:
 			inode->i_op = &page_symlink_inode_operations;
+			inode_nohighmem(inode);
 			inode->i_data.a_ops = &efs_symlink_aops;
 			break;
 		case S_IFCHR:
diff --git a/fs/efs/symlink.c b/fs/efs/symlink.c
index 75117d0..4870cc8 100644
--- a/fs/efs/symlink.c
+++ b/fs/efs/symlink.c
@@ -13,7 +13,7 @@
 
 static int efs_symlink_readpage(struct file *file, struct page *page)
 {
-	char *link = kmap(page);
+	char *link = page_address(page);
 	struct buffer_head * bh;
 	struct inode * inode = page->mapping->host;
 	efs_block_t size = inode->i_size;
@@ -39,12 +39,10 @@ static int efs_symlink_readpage(struct file *file, struct page *page)
 	}
 	link[size] = '\0';
 	SetPageUptodate(page);
-	kunmap(page);
 	unlock_page(page);
 	return 0;
 fail:
 	SetPageError(page);
-	kunmap(page);
 	unlock_page(page);
 	return err;
 }
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 73c64da..d8e9c181 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -1227,6 +1227,7 @@ struct inode *exofs_iget(struct super_block *sb, unsigned long ino)
 			inode->i_link = (char *)oi->i_data;
 		} else {
 			inode->i_op = &page_symlink_inode_operations;
+			inode_nohighmem(inode);
 			inode->i_mapping->a_ops = &exofs_aops;
 		}
 	} else {
diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
index 994e078..c20d77d 100644
--- a/fs/exofs/namei.c
+++ b/fs/exofs/namei.c
@@ -111,6 +111,7 @@ static int exofs_symlink(struct inode *dir, struct dentry *dentry,
 	if (l > sizeof(oi->i_data)) {
 		/* slow symlink */
 		inode->i_op = &page_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &exofs_aops;
 		memset(oi->i_data, 0, sizeof(oi->i_data));
 
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 0aa9bf6..338eefd 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1420,6 +1420,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
 				sizeof(ei->i_data) - 1);
 		} else {
 			inode->i_op = &ext2_symlink_inode_operations;
+			inode_nohighmem(inode);
 			if (test_opt(inode->i_sb, NOBH))
 				inode->i_mapping->a_ops = &ext2_nobh_aops;
 			else
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 3267a80d..7a2be8f 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -183,6 +183,7 @@ static int ext2_symlink (struct inode * dir, struct dentry * dentry,
 	if (l > sizeof (EXT2_I(inode)->i_data)) {
 		/* slow symlink */
 		inode->i_op = &ext2_symlink_inode_operations;
+		inode_nohighmem(inode);
 		if (test_opt(inode->i_sb, NOBH))
 			inode->i_mapping->a_ops = &ext2_nobh_aops;
 		else
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index ea433a7..b3bd912 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4283,6 +4283,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 			inode->i_op = &ext4_symlink_inode_operations;
 			ext4_set_aops(inode);
 		}
+		inode_nohighmem(inode);
 	} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
 	      S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
 		inode->i_op = &ext4_special_inode_operations;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index a969ab3..f27e0c2 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3132,6 +3132,7 @@ static int ext4_symlink(struct inode *dir,
 	if ((disk_link.len > EXT4_N_BLOCKS * 4)) {
 		if (!encryption_required)
 			inode->i_op = &ext4_symlink_inode_operations;
+		inode_nohighmem(inode);
 		ext4_set_aops(inode);
 		/*
 		 * We cannot call page_symlink() with transaction started
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c
index abe2401..0e6dc44 100644
--- a/fs/ext4/symlink.c
+++ b/fs/ext4/symlink.c
@@ -45,7 +45,7 @@ static const char *ext4_encrypted_follow_link(struct dentry *dentry, void **cook
 		cpage = read_mapping_page(inode->i_mapping, 0, NULL);
 		if (IS_ERR(cpage))
 			return ERR_CAST(cpage);
-		caddr = kmap(cpage);
+		caddr = page_address(cpage);
 		caddr[size] = 0;
 	}
 
@@ -75,16 +75,12 @@ static const char *ext4_encrypted_follow_link(struct dentry *dentry, void **cook
 	/* Null-terminate the name */
 	if (res <= plen)
 		paddr[res] = '\0';
-	if (cpage) {
-		kunmap(cpage);
+	if (cpage)
 		page_cache_release(cpage);
-	}
 	return *cookie = paddr;
 errout:
-	if (cpage) {
-		kunmap(cpage);
+	if (cpage)
 		page_cache_release(cpage);
-	}
 	kfree(paddr);
 	return ERR_PTR(res);
 }
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 97e20de..5528801 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -202,6 +202,7 @@ make_now:
 			inode->i_op = &f2fs_encrypted_symlink_inode_operations;
 		else
 			inode->i_op = &f2fs_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &f2fs_dblock_aops;
 	} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
 			S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 2c32110..484df68 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -351,6 +351,7 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
 		inode->i_op = &f2fs_encrypted_symlink_inode_operations;
 	else
 		inode->i_op = &f2fs_symlink_inode_operations;
+	inode_nohighmem(inode);
 	inode->i_mapping->a_ops = &f2fs_dblock_aops;
 
 	f2fs_lock_op(sbi);
@@ -942,7 +943,7 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void **cook
 	cpage = read_mapping_page(inode->i_mapping, 0, NULL);
 	if (IS_ERR(cpage))
 		return ERR_CAST(cpage);
-	caddr = kmap(cpage);
+	caddr = page_address(cpage);
 	caddr[size] = 0;
 
 	/* Symlink is encrypted */
@@ -982,13 +983,11 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void **cook
 	/* Null-terminate the name */
 	paddr[res] = '\0';
 
-	kunmap(cpage);
 	page_cache_release(cpage);
 	return *cookie = paddr;
 errout:
 	kfree(cstr.name);
 	f2fs_fname_crypto_free_buffer(&pstr);
-	kunmap(cpage);
 	page_cache_release(cpage);
 	return ERR_PTR(res);
 }
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
index ef73ed6..3e2ccad 100644
--- a/fs/freevxfs/vxfs_inode.c
+++ b/fs/freevxfs/vxfs_inode.c
@@ -326,6 +326,7 @@ vxfs_iget(struct super_block *sbp, ino_t ino)
 	} else if (S_ISLNK(ip->i_mode)) {
 		if (!VXFS_ISIMMED(vip)) {
 			ip->i_op = &page_symlink_inode_operations;
+			inode_nohighmem(ip);
 			ip->i_mapping->a_ops = &vxfs_aops;
 		} else {
 			ip->i_op = &simple_symlink_inode_operations;
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 6dd107d..19b33f8 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -403,6 +403,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode)
 	} else if (S_ISLNK(inode->i_mode)) {
 		sbi->file_count++;
 		inode->i_op = &page_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &hfsplus_aops;
 		hip->clump_blocks = 1;
 	} else
@@ -526,6 +527,7 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
 			inode->i_mapping->a_ops = &hfsplus_aops;
 		} else if (S_ISLNK(inode->i_mode)) {
 			inode->i_op = &page_symlink_inode_operations;
+			inode_nohighmem(inode);
 			inode->i_mapping->a_ops = &hfsplus_aops;
 		} else {
 			init_special_inode(inode, inode->i_mode,
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 933c737..1f3c6d7 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -77,6 +77,7 @@ void hpfs_read_inode(struct inode *i)
 			kfree(ea);
 			i->i_mode = S_IFLNK | 0777;
 			i->i_op = &page_symlink_inode_operations;
+			inode_nohighmem(i);
 			i->i_data.a_ops = &hpfs_symlink_aops;
 			set_nlink(i, 1);
 			i->i_size = ea_size;
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index ae4d5a1..506765a 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -332,6 +332,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
 	result->i_blocks = 1;
 	set_nlink(result, 1);
 	result->i_size = strlen(symlink);
+	inode_nohighmem(result);
 	result->i_op = &page_symlink_inode_operations;
 	result->i_data.a_ops = &hpfs_symlink_aops;
 
@@ -500,7 +501,7 @@ out:
 
 static int hpfs_symlink_readpage(struct file *file, struct page *page)
 {
-	char *link = kmap(page);
+	char *link = page_address(page);
 	struct inode *i = page->mapping->host;
 	struct fnode *fnode;
 	struct buffer_head *bh;
@@ -516,14 +517,12 @@ static int hpfs_symlink_readpage(struct file *file, struct page *page)
 		goto fail;
 	hpfs_unlock(i->i_sb);
 	SetPageUptodate(page);
-	kunmap(page);
 	unlock_page(page);
 	return 0;
 
 fail:
 	hpfs_unlock(i->i_sb);
 	SetPageError(page);
-	kunmap(page);
 	unlock_page(page);
 	return err;
 }
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index de4bdfa..d8f51ee 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -760,6 +760,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
 			break;
 		case S_IFLNK:
 			inode->i_op = &page_symlink_inode_operations;
+			inode_nohighmem(inode);
 			break;
 		}
 		lockdep_annotate_inode_mutex_key(inode);
diff --git a/fs/inode.c b/fs/inode.c
index 1be5f90..5bb85a0 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2028,3 +2028,9 @@ void inode_set_flags(struct inode *inode, unsigned int flags,
 				  new_flags) != old_flags));
 }
 EXPORT_SYMBOL(inode_set_flags);
+
+void inode_nohighmem(struct inode *inode)
+{
+	mapping_set_gfp_mask(inode->i_mapping, GFP_USER);
+}
+EXPORT_SYMBOL(inode_nohighmem);
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index d67a16f..61abdc4 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -1417,6 +1417,7 @@ static int isofs_read_inode(struct inode *inode, int relocated)
 		inode->i_fop = &isofs_dir_operations;
 	} else if (S_ISLNK(inode->i_mode)) {
 		inode->i_op = &page_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_data.a_ops = &isofs_symlink_aops;
 	} else
 		/* XXX - parse_rock_ridge_inode() had already set i_rdev. */
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 735d752..5384ceb 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -687,7 +687,7 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
 	struct inode *inode = page->mapping->host;
 	struct iso_inode_info *ei = ISOFS_I(inode);
 	struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb);
-	char *link = kmap(page);
+	char *link = page_address(page);
 	unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
 	struct buffer_head *bh;
 	char *rpnt = link;
@@ -774,7 +774,6 @@ repeat:
 	brelse(bh);
 	*rpnt = '\0';
 	SetPageUptodate(page);
-	kunmap(page);
 	unlock_page(page);
 	return 0;
 
@@ -791,7 +790,6 @@ fail:
 	brelse(bh);
 error:
 	SetPageError(page);
-	kunmap(page);
 	unlock_page(page);
 	return -EIO;
 }
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 41aa3ca..9d9bae6 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -60,6 +60,7 @@ struct inode *jfs_iget(struct super_block *sb, unsigned long ino)
 	} else if (S_ISLNK(inode->i_mode)) {
 		if (inode->i_size >= IDATASIZE) {
 			inode->i_op = &page_symlink_inode_operations;
+			inode_nohighmem(inode);
 			inode->i_mapping->a_ops = &jfs_aops;
 		} else {
 			inode->i_op = &jfs_fast_symlink_inode_operations;
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 9d7551f..701f893 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -983,6 +983,7 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
 		jfs_info("jfs_symlink: allocate extent ip:0x%p", ip);
 
 		ip->i_op = &jfs_symlink_inode_operations;
+		inode_nohighmem(ip);
 		ip->i_mapping->a_ops = &jfs_aops;
 
 		/*
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index 99944a4..542468e 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -529,6 +529,7 @@ static int logfs_symlink(struct inode *dir, struct dentry *dentry,
 		return PTR_ERR(inode);
 
 	inode->i_op = &page_symlink_inode_operations;
+	inode_nohighmem(inode);
 	inode->i_mapping->a_ops = &logfs_reg_aops;
 
 	return __logfs_create(dir, dentry, inode, target, destlen);
diff --git a/fs/logfs/inode.c b/fs/logfs/inode.c
index 06baa92..0fce46d 100644
--- a/fs/logfs/inode.c
+++ b/fs/logfs/inode.c
@@ -65,6 +65,7 @@ static void logfs_inode_setops(struct inode *inode)
 		break;
 	case S_IFLNK:
 		inode->i_op = &page_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &logfs_reg_aops;
 		break;
 	case S_IFSOCK:	/* fall through */
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 086cd0a..67a23bf 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -452,6 +452,7 @@ void minix_set_inode(struct inode *inode, dev_t rdev)
 		inode->i_mapping->a_ops = &minix_aops;
 	} else if (S_ISLNK(inode->i_mode)) {
 		inode->i_op = &minix_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &minix_aops;
 	} else
 		init_special_inode(inode, inode->i_mode, rdev);
diff --git a/fs/namei.c b/fs/namei.c
index 4bae5cb..2808958 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4527,7 +4527,8 @@ static const char *page_getlink(struct dentry * dentry, void **cookie)
 	if (IS_ERR(page))
 		return (char*)page;
 	*cookie = page;
-	kaddr = kmap(page);
+	BUG_ON(mapping_gfp_mask(mapping) & __GFP_HIGHMEM);
+	kaddr = page_address(page);
 	nd_terminate_link(kaddr, dentry->d_inode->i_size, PAGE_SIZE - 1);
 	return kaddr;
 }
@@ -4541,7 +4542,6 @@ EXPORT_SYMBOL(page_follow_link_light);
 void page_put_link(struct inode *unused, void *cookie)
 {
 	struct page *page = cookie;
-	kunmap(page);
 	page_cache_release(page);
 }
 EXPORT_SYMBOL(page_put_link);
@@ -4565,7 +4565,6 @@ int __page_symlink(struct inode *inode, const char *symname, int len, int nofs)
 	struct page *page;
 	void *fsdata;
 	int err;
-	char *kaddr;
 	unsigned int flags = AOP_FLAG_UNINTERRUPTIBLE;
 	if (nofs)
 		flags |= AOP_FLAG_NOFS;
@@ -4576,9 +4575,7 @@ retry:
 	if (err)
 		goto fail;
 
-	kaddr = kmap_atomic(page);
-	memcpy(kaddr, symname, len-1);
-	kunmap_atomic(kaddr);
+	memcpy(page_address(page), symname, len-1);
 
 	err = pagecache_write_end(NULL, mapping, 0, len-1, len-1,
 							page, fsdata);
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 9605a2f..bb856f7 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -283,6 +283,7 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info)
 #if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
 		} else if (S_ISLNK(inode->i_mode)) {
 			inode->i_op = &ncp_symlink_inode_operations;
+			inode_nohighmem(inode);
 			inode->i_data.a_ops = &ncp_symlink_aops;
 #endif
 		} else {
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 31b0a52..ae9aa0b 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -408,9 +408,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
 				inode->i_fop = NULL;
 				inode->i_flags |= S_AUTOMOUNT;
 			}
-		} else if (S_ISLNK(inode->i_mode))
+		} else if (S_ISLNK(inode->i_mode)) {
 			inode->i_op = &nfs_symlink_inode_operations;
-		else
+			inode_nohighmem(inode);
+		} else
 			init_special_inode(inode, inode->i_mode, fattr->rdev);
 
 		memset(&inode->i_atime, 0, sizeof(inode->i_atime));
diff --git a/fs/nfs/symlink.c b/fs/nfs/symlink.c
index b6de433..abd93bf 100644
--- a/fs/nfs/symlink.c
+++ b/fs/nfs/symlink.c
@@ -56,7 +56,7 @@ static const char *nfs_follow_link(struct dentry *dentry, void **cookie)
 	if (IS_ERR(page))
 		return ERR_CAST(page);
 	*cookie = page;
-	return kmap(page);
+	return page_address(page);
 }
 
 /*
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index ac2f649..10b2252 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -510,6 +510,7 @@ static int __nilfs_read_inode(struct super_block *sb,
 		inode->i_mapping->a_ops = &nilfs_aops;
 	} else if (S_ISLNK(inode->i_mode)) {
 		inode->i_op = &nilfs_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &nilfs_aops;
 	} else {
 		inode->i_op = &nilfs_special_inode_operations;
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index c9a1a49..90b3ba9 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -161,6 +161,7 @@ static int nilfs_symlink(struct inode *dir, struct dentry *dentry,
 
 	/* slow symlink */
 	inode->i_op = &nilfs_symlink_inode_operations;
+	inode_nohighmem(inode);
 	inode->i_mapping->a_ops = &nilfs_aops;
 	err = page_symlink(inode, symname, l);
 	if (err)
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 8f87e05..97a563b 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -361,6 +361,7 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
 		    break;
 	    case S_IFLNK:
 		    inode->i_op = &ocfs2_symlink_inode_operations;
+		    inode_nohighmem(inode);
 		    i_size_write(inode, le64_to_cpu(fe->i_size));
 		    break;
 	    default:
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index a03f6f4..2efe8af 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1960,6 +1960,7 @@ static int ocfs2_symlink(struct inode *dir,
 	inode->i_rdev = 0;
 	newsize = l - 1;
 	inode->i_op = &ocfs2_symlink_inode_operations;
+	inode_nohighmem(inode);
 	if (l > ocfs2_fast_symlink_chars(sb)) {
 		u32 offset = 0;
 
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index c4bcb77..f37b3de 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -316,6 +316,7 @@ struct inode *qnx4_iget(struct super_block *sb, unsigned long ino)
 		inode->i_fop = &qnx4_dir_operations;
 	} else if (S_ISLNK(inode->i_mode)) {
 		inode->i_op = &page_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &qnx4_aops;
 		qnx4_i(inode)->mmu_private = inode->i_size;
 	} else {
diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c
index 32d2e1a..9728b54 100644
--- a/fs/qnx6/inode.c
+++ b/fs/qnx6/inode.c
@@ -582,6 +582,7 @@ struct inode *qnx6_iget(struct super_block *sb, unsigned ino)
 		inode->i_mapping->a_ops = &qnx6_aops;
 	} else if (S_ISLNK(inode->i_mode)) {
 		inode->i_op = &page_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &qnx6_aops;
 	} else
 		init_special_inode(inode, inode->i_mode, 0);
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 889d558..38981b0 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -79,6 +79,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
 			break;
 		case S_IFLNK:
 			inode->i_op = &page_symlink_inode_operations;
+			inode_nohighmem(inode);
 			break;
 		}
 	}
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 3d8e7e6..ae9e5b3 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1361,6 +1361,7 @@ static void init_inode(struct inode *inode, struct treepath *path)
 		inode->i_fop = &reiserfs_dir_operations;
 	} else if (S_ISLNK(inode->i_mode)) {
 		inode->i_op = &reiserfs_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &reiserfs_address_space_operations;
 	} else {
 		inode->i_blocks = 0;
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 47f9698..4fc2326 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -1170,6 +1170,7 @@ static int reiserfs_symlink(struct inode *parent_dir,
 	reiserfs_update_inode_transaction(parent_dir);
 
 	inode->i_op = &reiserfs_symlink_inode_operations;
+	inode_nohighmem(inode);
 	inode->i_mapping->a_ops = &reiserfs_address_space_operations;
 
 	retval = reiserfs_add_entry(&th, parent_dir, dentry->d_name.name,
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index 268733c..bb894e7 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -360,6 +360,7 @@ static struct inode *romfs_iget(struct super_block *sb, unsigned long pos)
 		break;
 	case ROMFH_SYM:
 		i->i_op = &page_symlink_inode_operations;
+		inode_nohighmem(i);
 		i->i_data.a_ops = &romfs_aops;
 		mode |= S_IRWXUGO;
 		break;
diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
index a1ce5ce..0927b1e 100644
--- a/fs/squashfs/inode.c
+++ b/fs/squashfs/inode.c
@@ -41,6 +41,7 @@
 #include <linux/fs.h>
 #include <linux/vfs.h>
 #include <linux/xattr.h>
+#include <linux/pagemap.h>
 
 #include "squashfs_fs.h"
 #include "squashfs_fs_sb.h"
@@ -291,6 +292,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
 		set_nlink(inode, le32_to_cpu(sqsh_ino->nlink));
 		inode->i_size = le32_to_cpu(sqsh_ino->symlink_size);
 		inode->i_op = &squashfs_symlink_inode_ops;
+		inode_nohighmem(inode);
 		inode->i_data.a_ops = &squashfs_symlink_aops;
 		inode->i_mode |= S_IFLNK;
 		squashfs_i(inode)->start = block;
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index 02fa1dc..ef8bcdb 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -163,6 +163,7 @@ void sysv_set_inode(struct inode *inode, dev_t rdev)
 		inode->i_mapping->a_ops = &sysv_aops;
 	} else if (S_ISLNK(inode->i_mode)) {
 		inode->i_op = &sysv_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &sysv_aops;
 	} else
 		init_special_inode(inode, inode->i_mode, rdev);
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 8675c2b..0557463 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1541,6 +1541,7 @@ reread:
 	case ICBTAG_FILE_TYPE_SYMLINK:
 		inode->i_data.a_ops = &udf_symlink_aops;
 		inode->i_op = &page_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mode = S_IFLNK | S_IRWXUGO;
 		break;
 	case ICBTAG_FILE_TYPE_MAIN:
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index d0e6de1..42eafb9 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -922,6 +922,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 
 	inode->i_data.a_ops = &udf_symlink_aops;
 	inode->i_op = &page_symlink_inode_operations;
+	inode_nohighmem(inode);
 
 	if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
 		struct kernel_lb_addr eloc;
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
index 862535b..8d61977 100644
--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -107,7 +107,7 @@ static int udf_symlink_filler(struct file *file, struct page *page)
 	struct buffer_head *bh = NULL;
 	unsigned char *symlink;
 	int err;
-	unsigned char *p = kmap(page);
+	unsigned char *p = page_address(page);
 	struct udf_inode_info *iinfo;
 	uint32_t pos;
 
@@ -141,7 +141,6 @@ static int udf_symlink_filler(struct file *file, struct page *page)
 
 	up_read(&iinfo->i_data_sem);
 	SetPageUptodate(page);
-	kunmap(page);
 	unlock_page(page);
 	return 0;
 
@@ -149,7 +148,6 @@ out_unlock_inode:
 	up_read(&iinfo->i_data_sem);
 	SetPageError(page);
 out_unmap:
-	kunmap(page);
 	unlock_page(page);
 	return err;
 }
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 737160a..d897e16 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -533,6 +533,7 @@ static void ufs_set_inode_ops(struct inode *inode)
 		} else {
 			inode->i_mapping->a_ops = &ufs_aops;
 			inode->i_op = &page_symlink_inode_operations;
+			inode_nohighmem(inode);
 		}
 	} else
 		init_special_inode(inode, inode->i_mode,
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 24b0cbd..acf4a3b 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -124,6 +124,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,
 	if (l > UFS_SB(sb)->s_uspi->s_maxsymlinklen) {
 		/* slow symlink */
 		inode->i_op = &page_symlink_inode_operations;
+		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &ufs_aops;
 		err = page_symlink(inode, symname, l);
 		if (err)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 3aa5142..dfeda44 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3025,5 +3025,6 @@ static inline bool dir_relax(struct inode *inode)
 }
 
 extern bool path_noexec(const struct path *path);
+extern void inode_nohighmem(struct inode *inode);
 
 #endif /* _LINUX_FS_H */
diff --git a/mm/shmem.c b/mm/shmem.c
index 9187eee..64bf5ac 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2444,7 +2444,6 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
 	int len;
 	struct inode *inode;
 	struct page *page;
-	char *kaddr;
 	struct shmem_inode_info *info;
 
 	len = strlen(symname) + 1;
@@ -2483,9 +2482,8 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
 		}
 		inode->i_mapping->a_ops = &shmem_aops;
 		inode->i_op = &shmem_symlink_inode_operations;
-		kaddr = kmap_atomic(page);
-		memcpy(kaddr, symname, len);
-		kunmap_atomic(kaddr);
+		inode_nohighmem(inode);
+		memcpy(page_address(page), symname, len);
 		SetPageUptodate(page);
 		set_page_dirty(page);
 		unlock_page(page);
@@ -2506,13 +2504,12 @@ static const char *shmem_follow_link(struct dentry *dentry, void **cookie)
 		return ERR_PTR(error);
 	unlock_page(page);
 	*cookie = page;
-	return kmap(page);
+	return page_address(page);
 }
 
 static void shmem_put_link(struct inode *unused, void *cookie)
 {
 	struct page *page = cookie;
-	kunmap(page);
 	mark_page_accessed(page);
 	page_cache_release(page);
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299842 — [PATCH 12/13] kill free_page_put_link()

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:50 +0100
Subject[PATCH 12/13] kill free_page_put_link()
Message-ID<qM1Hc-6Hb-1@gated-at.bofh.it>
In reply to#1299835
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299843 — [PATCH 05/13] namei: page_getlink() and page_follow_link_light() are the same thing

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:50 +0100
Subject[PATCH 05/13] namei: page_getlink() and page_follow_link_light() are the same thing
Message-ID<qM1Hc-6Hb-3@gated-at.bofh.it>
In reply to#1299835
From: Al Viro <viro@zeniv.linux.org.uk>

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/namei.c | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 0c3974c..4bae5cb 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4518,7 +4518,7 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
 EXPORT_SYMBOL(generic_readlink);
 
 /* get the link contents into pagecache */
-static char *page_getlink(struct dentry * dentry, struct page **ppage)
+static const char *page_getlink(struct dentry * dentry, void **cookie)
 {
 	char *kaddr;
 	struct page *page;
@@ -4526,31 +4526,15 @@ static char *page_getlink(struct dentry * dentry, struct page **ppage)
 	page = read_mapping_page(mapping, 0, NULL);
 	if (IS_ERR(page))
 		return (char*)page;
-	*ppage = page;
+	*cookie = page;
 	kaddr = kmap(page);
 	nd_terminate_link(kaddr, dentry->d_inode->i_size, PAGE_SIZE - 1);
 	return kaddr;
 }
 
-int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
-{
-	struct page *page = NULL;
-	int res = readlink_copy(buffer, buflen, page_getlink(dentry, &page));
-	if (page) {
-		kunmap(page);
-		page_cache_release(page);
-	}
-	return res;
-}
-EXPORT_SYMBOL(page_readlink);
-
 const char *page_follow_link_light(struct dentry *dentry, void **cookie)
 {
-	struct page *page = NULL;
-	char *res = page_getlink(dentry, &page);
-	if (!IS_ERR(res))
-		*cookie = page;
-	return res;
+	return page_getlink(dentry, cookie);
 }
 EXPORT_SYMBOL(page_follow_link_light);
 
@@ -4562,6 +4546,16 @@ void page_put_link(struct inode *unused, void *cookie)
 }
 EXPORT_SYMBOL(page_put_link);
 
+int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
+{
+	void *cookie = NULL;
+	int res = readlink_copy(buffer, buflen, page_getlink(dentry, &cookie));
+	if (cookie)
+		page_put_link(NULL, cookie);
+	return res;
+}
+EXPORT_SYMBOL(page_readlink);
+
 /*
  * The nofs argument instructs pagecache_write_begin to pass AOP_FLAG_NOFS
  */
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299844 — [PATCH 10/13] teach proc_self_get_link()/proc_thread_self_get_link() to work in RCU mode

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:50 +0100
Subject[PATCH 10/13] teach proc_self_get_link()/proc_thread_self_get_link() to work in RCU mode
Message-ID<qM1Hc-6Hb-5@gated-at.bofh.it>
In reply to#1299835
From: Al Viro <viro@zeniv.linux.org.uk>

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/proc/self.c        | 8 +++-----
 fs/proc/thread_self.c | 9 ++++-----
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/fs/proc/self.c b/fs/proc/self.c
index 9dd0ae6..7a8b19e 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -25,14 +25,12 @@ static const char *proc_self_get_link(struct dentry *dentry,
 	pid_t tgid = task_tgid_nr_ns(current, ns);
 	char *name;
 
-	if (!dentry)
-		return ERR_PTR(-ECHILD);
 	if (!tgid)
 		return ERR_PTR(-ENOENT);
 	/* 11 for max length of signed int in decimal + NULL term */
-	name = kmalloc(12, GFP_KERNEL);
-	if (!name)
-		return ERR_PTR(-ENOMEM);
+	name = kmalloc(12, dentry ? GFP_KERNEL : GFP_ATOMIC);
+	if (unlikely(!name))
+		return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD);
 	sprintf(name, "%d", tgid);
 	return *cookie = name;
 }
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index 50eef6f..03eaa84 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -27,13 +27,12 @@ static const char *proc_thread_self_get_link(struct dentry *dentry,
 	pid_t pid = task_pid_nr_ns(current, ns);
 	char *name;
 
-	if (!dentry)
-		return ERR_PTR(-ECHILD);
 	if (!pid)
 		return ERR_PTR(-ENOENT);
-	name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, GFP_KERNEL);
-	if (!name)
-		return ERR_PTR(-ENOMEM);
+	name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF,
+				dentry ? GFP_KERNEL : GFP_ATOMIC);
+	if (unlikely(!name))
+		return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD);
 	sprintf(name, "%d/task/%d", tgid, pid);
 	return *cookie = name;
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299845 — [PATCH 08/13] teach page_get_link() to work in RCU mode

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:50 +0100
Subject[PATCH 08/13] teach page_get_link() to work in RCU mode
Message-ID<qM1Hc-6Hb-7@gated-at.bofh.it>
In reply to#1299835
From: Al Viro <viro@zeniv.linux.org.uk>

more or less along the lines of Neil's patchset, sans the insanity
around kmap().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/namei.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 1da3064..8f51788 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4533,12 +4533,19 @@ const char *page_get_link(struct dentry *dentry, struct inode *inode,
 	struct page *page;
 	struct address_space *mapping = inode->i_mapping;
 
-	if (!dentry)
-		return ERR_PTR(-ECHILD);
-
-	page = read_mapping_page(mapping, 0, NULL);
-	if (IS_ERR(page))
-		return (char*)page;
+	if (!dentry) {
+		page = find_get_page(mapping, 0);
+		if (!page)
+			return ERR_PTR(-ECHILD);
+		if (!PageUptodate(page)) {
+			put_page(page);
+			return ERR_PTR(-ECHILD);
+		}
+	} else {
+		page = read_mapping_page(mapping, 0, NULL);
+		if (IS_ERR(page))
+			return (char*)page;
+	}
 	*cookie = page;
 	BUG_ON(mapping_gfp_mask(mapping) & __GFP_HIGHMEM);
 	kaddr = page_address(page);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1299846 — [PATCH 04/13] ufs: get rid of ->setattr() for symlinks

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-01 07:50 +0100
Subject[PATCH 04/13] ufs: get rid of ->setattr() for symlinks
Message-ID<qM1Hc-6Hb-9@gated-at.bofh.it>
In reply to#1299835
From: Al Viro <viro@zeniv.linux.org.uk>

It was to needed for a couple of months in 2010, until UFS
quota support got dropped.  Since then it's equivalent to
simple_setattr() (i.e. the default) for everything except the
regular files.  And dropping it there allows to convert all
UFS symlinks to {page,simple}_symlink_inode_operations, getting
rid of fs/ufs/symlink.c completely.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/ufs/Makefile  |  2 +-
 fs/ufs/inode.c   |  4 ++--
 fs/ufs/namei.c   |  4 ++--
 fs/ufs/symlink.c | 42 ------------------------------------------
 fs/ufs/ufs.h     |  4 ----
 5 files changed, 5 insertions(+), 51 deletions(-)
 delete mode 100644 fs/ufs/symlink.c

diff --git a/fs/ufs/Makefile b/fs/ufs/Makefile
index 392db25..ec4a6b4 100644
--- a/fs/ufs/Makefile
+++ b/fs/ufs/Makefile
@@ -5,5 +5,5 @@
 obj-$(CONFIG_UFS_FS) += ufs.o
 
 ufs-objs := balloc.o cylinder.o dir.o file.o ialloc.o inode.o \
-	    namei.o super.o symlink.o util.o
+	    namei.o super.o util.o
 ccflags-$(CONFIG_UFS_DEBUG)    += -DDEBUG
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index a064cf44..737160a 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -528,11 +528,11 @@ static void ufs_set_inode_ops(struct inode *inode)
 		inode->i_mapping->a_ops = &ufs_aops;
 	} else if (S_ISLNK(inode->i_mode)) {
 		if (!inode->i_blocks) {
-			inode->i_op = &ufs_fast_symlink_inode_operations;
 			inode->i_link = (char *)UFS_I(inode)->i_u1.i_symlink;
+			inode->i_op = &simple_symlink_inode_operations;
 		} else {
-			inode->i_op = &ufs_symlink_inode_operations;
 			inode->i_mapping->a_ops = &ufs_aops;
+			inode->i_op = &page_symlink_inode_operations;
 		}
 	} else
 		init_special_inode(inode, inode->i_mode,
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 4796655..24b0cbd 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -123,14 +123,14 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,
 
 	if (l > UFS_SB(sb)->s_uspi->s_maxsymlinklen) {
 		/* slow symlink */
-		inode->i_op = &ufs_symlink_inode_operations;
+		inode->i_op = &page_symlink_inode_operations;
 		inode->i_mapping->a_ops = &ufs_aops;
 		err = page_symlink(inode, symname, l);
 		if (err)
 			goto out_fail;
 	} else {
 		/* fast symlink */
-		inode->i_op = &ufs_fast_symlink_inode_operations;
+		inode->i_op = &simple_symlink_inode_operations;
 		inode->i_link = (char *)UFS_I(inode)->i_u1.i_symlink;
 		memcpy(inode->i_link, symname, l);
 		inode->i_size = l-1;
diff --git a/fs/ufs/symlink.c b/fs/ufs/symlink.c
deleted file mode 100644
index 874480b..0000000
--- a/fs/ufs/symlink.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  linux/fs/ufs/symlink.c
- *
- * Only fast symlinks left here - the rest is done by generic code. AV, 1999
- *
- * Copyright (C) 1998
- * Daniel Pirkl <daniel.pirkl@emai.cz>
- * Charles University, Faculty of Mathematics and Physics
- *
- *  from
- *
- *  linux/fs/ext2/symlink.c
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- *  from
- *
- *  linux/fs/minix/symlink.c
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- *
- *  ext2 symlink handling code
- */
-
-#include "ufs_fs.h"
-#include "ufs.h"
-
-const struct inode_operations ufs_fast_symlink_inode_operations = {
-	.readlink	= generic_readlink,
-	.follow_link	= simple_follow_link,
-	.setattr	= ufs_setattr,
-};
-
-const struct inode_operations ufs_symlink_inode_operations = {
-	.readlink	= generic_readlink,
-	.follow_link	= page_follow_link_light,
-	.put_link	= page_put_link,
-	.setattr	= ufs_setattr,
-};
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 7da4aca..c87f4c3 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -136,10 +136,6 @@ extern __printf(3, 4)
 void ufs_panic(struct super_block *, const char *, const char *, ...);
 void ufs_mark_sb_dirty(struct super_block *sb);
 
-/* symlink.c */
-extern const struct inode_operations ufs_fast_symlink_inode_operations;
-extern const struct inode_operations ufs_symlink_inode_operations;
-
 static inline struct ufs_sb_info *UFS_SB(struct super_block *sb)
 {
 	return sb->s_fs_info;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300378

FromLinus Torvalds <torvalds@linux-foundation.org>
Date2016-01-03 21:00 +0100
Message-ID<qMWYP-1kX-27@gated-at.bofh.it>
In reply to#1299835
On Thu, Dec 31, 2015 at 10:36 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
>         In cases when we need to pin the symlink body in some manner, we
> need to undo whatever we'd done once the caller is done with the body.
> That went through several variants, the latest (in -next right now) being
> "have non-NULL ->put_link() and leave an argument for it in void *cookie,
> address of which is passed to ->get_link()".

The series looks ok to me, even if I still am not a fan of the cookie.
I suspect the remaining users could easily embed the returned string
at the end of a structure, and get their data with container_of(). It
would complicate their unusual behavior for sure, but make the common
case much more understandable.

Oh well. I won't insist - it may be too painful to be worth it. And
it's a fairly separate issue anyway.

So no objections to this series.

              Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300384

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-03 21:30 +0100
Message-ID<qMXrQ-1KX-7@gated-at.bofh.it>
In reply to#1300378
On Sun, Jan 03, 2016 at 11:53:21AM -0800, Linus Torvalds wrote:
> On Thu, Dec 31, 2015 at 10:36 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> >         In cases when we need to pin the symlink body in some manner, we
> > need to undo whatever we'd done once the caller is done with the body.
> > That went through several variants, the latest (in -next right now) being
> > "have non-NULL ->put_link() and leave an argument for it in void *cookie,
> > address of which is passed to ->get_link()".
> 
> The series looks ok to me, even if I still am not a fan of the cookie.
> I suspect the remaining users could easily embed the returned string
> at the end of a structure, and get their data with container_of(). It
> would complicate their unusual behavior for sure, but make the common
> case much more understandable.
> 
> Oh well. I won't insist - it may be too painful to be worth it. And
> it's a fairly separate issue anyway.
> 
> So no objections to this series.

Just to make sure - that does include 13/13, presumably?  IOW, ->put_link()
is gone and the final calling conventions for ->get_link() are
	const char *(*get_link)(struct dentry *dentry,
				struct inode *inode,
				struct delayed_call *done);
with dentry == NULL <=> call in RCU mode, ERR_PTR(-E...) returned on error
and set_delayed_call(done, destructor, arg) done if destructor(arg) should
be done once pathname resolution is through with the body returned by
->get_link().
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300388

FromLinus Torvalds <torvalds@linux-foundation.org>
Date2016-01-03 21:50 +0100
Message-ID<qMXLc-1Rv-5@gated-at.bofh.it>
In reply to#1300384
On Sun, Jan 3, 2016 at 12:21 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> Just to make sure - that does include 13/13, presumably?

Ugh, no, I had set that aside and then forgot all about it.

I'm not sure about 13/13.  I'm ok with it, but I'm not sure it's any
less confusing than the cookie was.

I like how it removes "put_link()" as a callback, but at the same time
I think it's even more abstract than the cookie was.

The main worry I have is that the naming is generic, but there's only
a single very specialized use for it. Do we expect other uses?

Because if not, I think it would be clearer if it was named to be more
concretely about putlink, and avoid the fact that it feels very
abstract.

Don't get me wrong - abstract generalized helper functions are cool.
But people aren't very abstract, and it tends to make for confusing
code when you aren't intimately familiar with the rules.

                 Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1300399

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-03 22:50 +0100
Message-ID<qMYHh-2vF-13@gated-at.bofh.it>
In reply to#1300388
On Sun, Jan 03, 2016 at 12:41:47PM -0800, Linus Torvalds wrote:

> I like how it removes "put_link()" as a callback, but at the same time
> I think it's even more abstract than the cookie was.
> 
> The main worry I have is that the naming is generic, but there's only
> a single very specialized use for it. Do we expect other uses?

Quite possibly - I don't have anything specific planned right now, but
I would be surprised if there hadn't been open-coded equivalents
of that thing in many places, and not only "too many instances to touch"
kind of holy cows, at that (timers are obviously very similar, but these
_do_ have way too many instances to even think of converting them).

> Because if not, I think it would be clearer if it was named to be more
> concretely about putlink, and avoid the fact that it feels very
> abstract.
> 
> Don't get me wrong - abstract generalized helper functions are cool.
> But people aren't very abstract, and it tends to make for confusing
> code when you aren't intimately familiar with the rules.

The rules are pretty simple - there are 4 primitives total.
1) DEFINE_DELAYED_CALL(name) - usual DEFINE_MUTEX, etc. style initialized
declaration.
2) set_delayed_call(delayed_call, function, argument) - function is
void(void *), argument is void *.  A-la setup_timer().
3) clear_delayed_call(delayed_call) - resets.
4) do_delayed_call(delayed_call) - evaluates.

That's it.  If you have better suggestions re names, I'd be glad to take
them, but the set of primitives and the rules to go with those are as
simple as it gets.

Sure, we can give it a less generic name for now and just do what we'd done
for another generic thing (rcu_head, aka callback_head) when unrelated
uses show up, but I don't see much point going that way, TBH...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web