[PATCH 00/17] clean up readlinks

From: Miklos Szeredi
Date: Mon Sep 12 2016 - 15:35:04 EST


The first patch is actually a bug fix, but I put it into this bunch for
simplicity...

The rest are really cleanups as well as minor bugfixes that are byproducts
of the cleanups.

This series builds on the fact that i_op.readlink is already set to
generic_readlink() in 43/50 of the cases. And of those 7 only 4 are doing
something special. So more than 90% of readlinks are/could actually just
call back into get_link.

The interesting cases are:

- AFS, which has readlink but not get_link
- proc, that allow jumping while following symlinks

The first is handled by setting IOP_NOFOLLOW on the inode by the fs.

The second one is handled by introducing is_following_link() which returns
a bool depending on whether current->nameidata is NULL or not. If it
returns false ->get_link() should behave as ->readlink() did. Otherwise it
should behave as id did previously.

Builds and boots. Can even read symlinks.

Git tree is here:

git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git readlink

Thanks,
Miklos
---

Miklos Szeredi (17):
bad_inode: add missing i_op initializers
ovl: use generic_readlink
proc/self: use generic_readlink
afs: use generic_readlink
bad_inode: use generic_readlink
vfs: remove page_readlink()
vfs: add is_following_link() helper
proc: merge proc_pid_readlink() into proc_pid_get_link()
proc: merge proc_ns_readlink() into proc_ns_get_link()
nsfs: clean up ns_get_name() interface
vfs: replace calling i_op->readlink with vfs_readlink()
vfs: remove ".readlink = generic_readlink" assignments
vfs: remove unused i_op->readlink
vfs: remove unused generic_readlink()
vfs: add vfs_get_link() helper
ovl: use vfs_get_link()
ecryptfs: use vfs_get_link()

Documentation/filesystems/Locking | 2 -
Documentation/filesystems/porting | 15 +++++
Documentation/filesystems/vfs.txt | 25 ++++----
drivers/staging/lustre/lustre/llite/symlink.c | 1 -
fs/9p/vfs_inode.c | 1 -
fs/9p/vfs_inode_dotl.c | 1 -
fs/affs/symlink.c | 1 -
fs/afs/inode.c | 2 +
fs/afs/mntpt.c | 2 +-
fs/autofs4/symlink.c | 1 -
fs/bad_inode.c | 62 ++++++++++++++++----
fs/btrfs/inode.c | 1 -
fs/ceph/inode.c | 1 -
fs/cifs/cifsfs.c | 1 -
fs/coda/cnode.c | 1 -
fs/configfs/symlink.c | 1 -
fs/ecryptfs/inode.c | 30 ++++------
fs/ext2/symlink.c | 2 -
fs/ext4/symlink.c | 3 -
fs/f2fs/namei.c | 2 -
fs/fuse/dir.c | 1 -
fs/gfs2/inode.c | 1 -
fs/hostfs/hostfs_kern.c | 1 -
fs/jffs2/symlink.c | 1 -
fs/jfs/symlink.c | 2 -
fs/kernfs/symlink.c | 1 -
fs/libfs.c | 1 -
fs/minix/inode.c | 1 -
fs/namei.c | 82 ++++++++++++++++++++-------
fs/ncpfs/inode.c | 1 -
fs/nfs/symlink.c | 1 -
fs/nfsd/nfs4xdr.c | 8 +--
fs/nfsd/vfs.c | 4 +-
fs/nilfs2/namei.c | 1 -
fs/nsfs.c | 17 ++++--
fs/ocfs2/symlink.c | 1 -
fs/orangefs/symlink.c | 1 -
fs/overlayfs/copy_up.c | 46 ++-------------
fs/overlayfs/inode.c | 25 +-------
fs/proc/base.c | 66 +++++++--------------
fs/proc/inode.c | 1 -
fs/proc/namespaces.c | 41 +++++---------
fs/proc/self.c | 13 -----
fs/proc/thread_self.c | 14 -----
fs/reiserfs/namei.c | 1 -
fs/squashfs/symlink.c | 1 -
fs/stat.c | 5 +-
fs/sysv/inode.c | 1 -
fs/ubifs/file.c | 1 -
fs/xfs/xfs_ioctl.c | 4 +-
fs/xfs/xfs_iops.c | 2 -
include/linux/fs.h | 9 ++-
include/linux/namei.h | 1 +
include/linux/proc_ns.h | 4 +-
mm/shmem.c | 2 -
55 files changed, 226 insertions(+), 291 deletions(-)

--
2.5.5