Skip to content

Commit

Permalink
Merge branch 'work.symlinks' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/viro/vfs

Pull vfs RCU symlink updates from Al Viro:
 "Replacement of ->follow_link/->put_link, allowing to stay in RCU mode
  even if the symlink is not an embedded one.

  No changes since the mailbomb on Jan 1"

* 'work.symlinks' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  switch ->get_link() to delayed_call, kill ->put_link()
  kill free_page_put_link()
  teach nfs_get_link() to work in RCU mode
  teach proc_self_get_link()/proc_thread_self_get_link() to work in RCU mode
  teach shmem_get_link() to work in RCU mode
  teach page_get_link() to work in RCU mode
  replace ->follow_link() with new method that could stay in RCU mode
  don't put symlink bodies in pagecache into highmem
  namei: page_getlink() and page_follow_link_light() are the same thing
  ufs: get rid of ->setattr() for symlinks
  udf: don't duplicate page_symlink_inode_operations
  logfs: don't duplicate page_symlink_inode_operations
  switch befs long symlinks to page_symlink_operations
  • Loading branch information
torvalds committed Jan 11, 2016
2 parents 19ccb28 + fceef39 commit 32fb378
Show file tree
Hide file tree
Showing 95 changed files with 570 additions and 470 deletions.
6 changes: 2 additions & 4 deletions Documentation/filesystems/Locking
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ prototypes:
int (*rename2) (struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
int (*readlink) (struct dentry *, char __user *,int);
const char *(*follow_link) (struct dentry *, void **);
void (*put_link) (struct inode *, void *);
const char *(*get_link) (struct dentry *, struct inode *, void **);
void (*truncate) (struct inode *);
int (*permission) (struct inode *, int, unsigned int);
int (*get_acl)(struct inode *, int);
Expand Down Expand Up @@ -83,8 +82,7 @@ rmdir: yes (both) (see below)
rename: yes (all) (see below)
rename2: yes (all) (see below)
readlink: no
follow_link: no
put_link: no
get_link: no
setattr: yes
permission: no (may not block if called in rcu-walk mode)
get_acl: no
Expand Down
17 changes: 17 additions & 0 deletions Documentation/filesystems/porting
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,20 @@ 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.
--
[mandatory]
->follow_link() is replaced with ->get_link(); same API, except that
* ->get_link() gets inode as a separate argument
* ->get_link() may be called in RCU mode - in that case NULL
dentry is passed
--
[mandatory]
->get_link() gets struct delayed_call *done now, and should do
set_delayed_call() where it used to set *cookie.
->put_link() is gone - just give the destructor to set_delayed_call()
in ->get_link().
21 changes: 10 additions & 11 deletions Documentation/filesystems/vfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ struct inode_operations {
int (*rename2) (struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
int (*readlink) (struct dentry *, char __user *,int);
const char *(*follow_link) (struct dentry *, void **);
void (*put_link) (struct inode *, void *);
const char *(*get_link) (struct dentry *, struct inode *,
struct delayed_call *);
int (*permission) (struct inode *, int);
int (*get_acl)(struct inode *, int);
int (*setattr) (struct dentry *, struct iattr *);
Expand Down Expand Up @@ -434,20 +434,19 @@ otherwise noted.
readlink: called by the readlink(2) system call. Only required if
you want to support reading symbolic links

follow_link: called by the VFS to follow a symbolic link to the
get_link: called by the VFS to follow a symbolic link to the
inode it points to. Only required if you want to support
symbolic links. This method returns the symlink body
to traverse (and possibly resets the current position with
nd_jump_link()). If the body won't go away until the inode
is gone, nothing else is needed; if it needs to be otherwise
pinned, the data needed to release whatever we'd grabbed
is to be stored in void * variable passed by address to
follow_link() instance.

put_link: called by the VFS to release resources allocated by
follow_link(). The cookie stored by follow_link() is passed
to this method as the last parameter; only called when
cookie isn't NULL.
pinned, arrange for its release by having get_link(..., ..., done)
do set_delayed_call(done, destructor, argument).
In that case destructor(argument) will be called once VFS is
done with the body you've returned.
May be called in RCU mode; that is indicated by NULL dentry
argument. If request can't be handled without leaving RCU mode,
have it return ERR_PTR(-ECHILD).

permission: called by the VFS to check for access rights on a POSIX-like
filesystem.
Expand Down
24 changes: 13 additions & 11 deletions drivers/staging/lustre/lustre/llite/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,20 @@ static int ll_readlink_internal(struct inode *inode,
return rc;
}

static const char *ll_follow_link(struct dentry *dentry, void **cookie)
static void ll_put_link(void *p)
{
ptlrpc_req_finished(p);
}

static const char *ll_get_link(struct dentry *dentry,
struct inode *inode,
struct delayed_call *done)
{
struct inode *inode = d_inode(dentry);
struct ptlrpc_request *request = NULL;
int rc;
char *symname = NULL;
if (!dentry)
return ERR_PTR(-ECHILD);

CDEBUG(D_VFSTRACE, "VFS Op\n");
ll_inode_size_lock(inode);
Expand All @@ -135,22 +143,16 @@ static const char *ll_follow_link(struct dentry *dentry, void **cookie)
}

/* symname may contain a pointer to the request message buffer,
* we delay request releasing until ll_put_link then.
* we delay request releasing then.
*/
*cookie = request;
set_delayed_call(done, ll_put_link, request);
return symname;
}

static void ll_put_link(struct inode *unused, void *cookie)
{
ptlrpc_req_finished(cookie);
}

struct inode_operations ll_fast_symlink_inode_operations = {
.readlink = generic_readlink,
.setattr = ll_setattr,
.follow_link = ll_follow_link,
.put_link = ll_put_link,
.get_link = ll_get_link,
.getattr = ll_getattr,
.permission = ll_inode_permission,
.setxattr = ll_setxattr,
Expand Down
24 changes: 16 additions & 8 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1223,18 +1223,26 @@ ino_t v9fs_qid2ino(struct p9_qid *qid)
}

/**
* v9fs_vfs_follow_link - follow a symlink path
* v9fs_vfs_get_link - follow a symlink path
* @dentry: dentry for symlink
* @cookie: place to pass the data to put_link()
* @inode: inode for symlink
* @done: delayed call for when we are done with the return value
*/

static const char *v9fs_vfs_follow_link(struct dentry *dentry, void **cookie)
static const char *v9fs_vfs_get_link(struct dentry *dentry,
struct inode *inode,
struct delayed_call *done)
{
struct v9fs_session_info *v9ses = v9fs_dentry2v9ses(dentry);
struct p9_fid *fid = v9fs_fid_lookup(dentry);
struct v9fs_session_info *v9ses;
struct p9_fid *fid;
struct p9_wstat *st;
char *res;

if (!dentry)
return ERR_PTR(-ECHILD);

v9ses = v9fs_dentry2v9ses(dentry);
fid = v9fs_fid_lookup(dentry);
p9_debug(P9_DEBUG_VFS, "%pd\n", dentry);

if (IS_ERR(fid))
Expand All @@ -1259,7 +1267,8 @@ static const char *v9fs_vfs_follow_link(struct dentry *dentry, void **cookie)

p9stat_free(st);
kfree(st);
return *cookie = res;
set_delayed_call(done, kfree_link, res);
return res;
}

/**
Expand Down Expand Up @@ -1452,8 +1461,7 @@ static const struct inode_operations v9fs_file_inode_operations = {

static const struct inode_operations v9fs_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = v9fs_vfs_follow_link,
.put_link = kfree_put_link,
.get_link = v9fs_vfs_get_link,
.getattr = v9fs_vfs_getattr,
.setattr = v9fs_vfs_setattr,
};
Expand Down
21 changes: 14 additions & 7 deletions fs/9p/vfs_inode_dotl.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,26 +899,34 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
}

/**
* v9fs_vfs_follow_link_dotl - follow a symlink path
* v9fs_vfs_get_link_dotl - follow a symlink path
* @dentry: dentry for symlink
* @cookie: place to pass the data to put_link()
* @inode: inode for symlink
* @done: destructor for return value
*/

static const char *
v9fs_vfs_follow_link_dotl(struct dentry *dentry, void **cookie)
v9fs_vfs_get_link_dotl(struct dentry *dentry,
struct inode *inode,
struct delayed_call *done)
{
struct p9_fid *fid = v9fs_fid_lookup(dentry);
struct p9_fid *fid;
char *target;
int retval;

if (!dentry)
return ERR_PTR(-ECHILD);

p9_debug(P9_DEBUG_VFS, "%pd\n", dentry);

fid = v9fs_fid_lookup(dentry);
if (IS_ERR(fid))
return ERR_CAST(fid);
retval = p9_client_readlink(fid, &target);
if (retval)
return ERR_PTR(retval);
return *cookie = target;
set_delayed_call(done, kfree_link, target);
return target;
}

int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode)
Expand Down Expand Up @@ -984,8 +992,7 @@ const struct inode_operations v9fs_file_inode_operations_dotl = {

const struct inode_operations v9fs_symlink_inode_operations_dotl = {
.readlink = generic_readlink,
.follow_link = v9fs_vfs_follow_link_dotl,
.put_link = kfree_put_link,
.get_link = v9fs_vfs_get_link_dotl,
.getattr = v9fs_vfs_getattr_dotl,
.setattr = v9fs_vfs_setattr_dotl,
.setxattr = generic_setxattr,
Expand Down
1 change: 1 addition & 0 deletions fs/affs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions fs/affs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions fs/affs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ 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;
char lc;

pr_debug("follow_link(ino=%lu)\n", inode->i_ino);
pr_debug("get_link(ino=%lu)\n", inode->i_ino);

bh = affs_bread(inode->i_sb, inode->i_ino);
if (!bh)
Expand Down Expand Up @@ -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;
}
Expand All @@ -73,7 +71,6 @@ const struct address_space_operations affs_symlink_aops = {

const struct inode_operations affs_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = page_follow_link_light,
.put_link = page_put_link,
.get_link = page_get_link,
.setattr = affs_notify_change,
};
1 change: 1 addition & 0 deletions fs/afs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
14 changes: 10 additions & 4 deletions fs/autofs4/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@

#include "autofs_i.h"

static const char *autofs4_follow_link(struct dentry *dentry, void **cookie)
static const char *autofs4_get_link(struct dentry *dentry,
struct inode *inode,
struct delayed_call *done)
{
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
struct autofs_info *ino = autofs4_dentry_ino(dentry);
struct autofs_sb_info *sbi;
struct autofs_info *ino;
if (!dentry)
return ERR_PTR(-ECHILD);
sbi = autofs4_sbi(dentry->d_sb);
ino = autofs4_dentry_ino(dentry);
if (ino && !autofs4_oz_mode(sbi))
ino->last_used = jiffies;
return d_inode(dentry)->i_private;
}

const struct inode_operations autofs4_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = autofs4_follow_link
.get_link = autofs4_get_link
};
Loading

0 comments on commit 32fb378

Please sign in to comment.