Skip to content

Commit

Permalink
switch ->get_link() to delayed_call, kill ->put_link()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Dec 30, 2015
1 parent cd3417c commit fceef39
Show file tree
Hide file tree
Showing 43 changed files with 206 additions and 218 deletions.
2 changes: 0 additions & 2 deletions Documentation/filesystems/Locking
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ prototypes:
struct inode *, struct dentry *, unsigned int);
int (*readlink) (struct dentry *, char __user *,int);
const char *(*get_link) (struct dentry *, struct inode *, void **);
void (*put_link) (struct inode *, void *);
void (*truncate) (struct inode *);
int (*permission) (struct inode *, int, unsigned int);
int (*get_acl)(struct inode *, int);
Expand Down Expand Up @@ -84,7 +83,6 @@ rename: yes (all) (see below)
rename2: yes (all) (see below)
readlink: no
get_link: no
put_link: no
setattr: yes
permission: no (may not block if called in rcu-walk mode)
get_acl: no
Expand Down
6 changes: 6 additions & 0 deletions Documentation/filesystems/porting
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,9 @@ in your dentry operations instead.
* ->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
18 changes: 9 additions & 9 deletions drivers/staging/lustre/lustre/llite/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,14 @@ static int ll_readlink_internal(struct inode *inode,
return rc;
}

static void ll_put_link(void *p)
{
ptlrpc_req_finished(p);
}

static const char *ll_get_link(struct dentry *dentry,
struct inode *inode, void **cookie)
struct inode *inode,
struct delayed_call *done)
{
struct ptlrpc_request *request = NULL;
int rc;
Expand All @@ -137,22 +143,16 @@ static const char *ll_get_link(struct dentry *dentry,
}

/* 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,
.get_link = ll_get_link,
.put_link = ll_put_link,
.getattr = ll_getattr,
.permission = ll_inode_permission,
.setxattr = ll_setxattr,
Expand Down
9 changes: 5 additions & 4 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1226,11 +1226,12 @@ ino_t v9fs_qid2ino(struct p9_qid *qid)
* v9fs_vfs_get_link - follow a symlink path
* @dentry: dentry for symlink
* @inode: inode for symlink
* @cookie: place to pass the data to put_link()
* @done: delayed call for when we are done with the return value
*/

static const char *v9fs_vfs_get_link(struct dentry *dentry,
struct inode *inode, void **cookie)
struct inode *inode,
struct delayed_call *done)
{
struct v9fs_session_info *v9ses;
struct p9_fid *fid;
Expand Down Expand Up @@ -1266,7 +1267,8 @@ static const char *v9fs_vfs_get_link(struct dentry *dentry,

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

/**
Expand Down Expand Up @@ -1460,7 +1462,6 @@ static const struct inode_operations v9fs_file_inode_operations = {
static const struct inode_operations v9fs_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = v9fs_vfs_get_link,
.put_link = kfree_put_link,
.getattr = v9fs_vfs_getattr,
.setattr = v9fs_vfs_setattr,
};
Expand Down
9 changes: 5 additions & 4 deletions fs/9p/vfs_inode_dotl.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,12 +902,13 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
* v9fs_vfs_get_link_dotl - follow a symlink path
* @dentry: dentry for symlink
* @inode: inode for symlink
* @cookie: place to pass the data to put_link()
* @done: destructor for return value
*/

static const char *
v9fs_vfs_get_link_dotl(struct dentry *dentry,
struct inode *inode, void **cookie)
struct inode *inode,
struct delayed_call *done)
{
struct p9_fid *fid;
char *target;
Expand All @@ -924,7 +925,8 @@ v9fs_vfs_get_link_dotl(struct dentry *dentry,
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 @@ -991,7 +993,6 @@ const struct inode_operations v9fs_file_inode_operations_dotl = {
const struct inode_operations v9fs_symlink_inode_operations_dotl = {
.readlink = generic_readlink,
.get_link = v9fs_vfs_get_link_dotl,
.put_link = kfree_put_link,
.getattr = v9fs_vfs_getattr_dotl,
.setattr = v9fs_vfs_setattr_dotl,
.setxattr = generic_setxattr,
Expand Down
1 change: 0 additions & 1 deletion fs/affs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,5 @@ const struct address_space_operations affs_symlink_aops = {
const struct inode_operations affs_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.put_link = page_put_link,
.setattr = affs_notify_change,
};
3 changes: 2 additions & 1 deletion fs/autofs4/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include "autofs_i.h"

static const char *autofs4_get_link(struct dentry *dentry,
struct inode *inode, void **cookie)
struct inode *inode,
struct delayed_call *done)
{
struct autofs_sb_info *sbi;
struct autofs_info *ino;
Expand Down
1 change: 0 additions & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -10097,7 +10097,6 @@ static const struct inode_operations btrfs_special_inode_operations = {
static const struct inode_operations btrfs_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.put_link = page_put_link,
.getattr = btrfs_getattr,
.setattr = btrfs_setattr,
.permission = btrfs_permission,
Expand Down
1 change: 0 additions & 1 deletion fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,6 @@ const struct inode_operations cifs_file_inode_ops = {
const struct inode_operations cifs_symlink_inode_ops = {
.readlink = generic_readlink,
.get_link = cifs_get_link,
.put_link = kfree_put_link,
.permission = cifs_permission,
/* BB add the following two eventually */
/* revalidate: cifs_revalidate,
Expand Down
3 changes: 2 additions & 1 deletion fs/cifs/cifsfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ extern struct vfsmount *cifs_dfs_d_automount(struct path *path);
#endif

/* Functions related to symlinks */
extern const char *cifs_get_link(struct dentry *, struct inode *, void **);
extern const char *cifs_get_link(struct dentry *, struct inode *,
struct delayed_call *);
extern int cifs_symlink(struct inode *inode, struct dentry *direntry,
const char *symname);
extern int cifs_removexattr(struct dentry *, const char *);
Expand Down
6 changes: 4 additions & 2 deletions fs/cifs/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
}

const char *
cifs_get_link(struct dentry *direntry, struct inode *inode, void **cookie)
cifs_get_link(struct dentry *direntry, struct inode *inode,
struct delayed_call *done)
{
int rc = -ENOMEM;
unsigned int xid;
Expand Down Expand Up @@ -680,7 +681,8 @@ cifs_get_link(struct dentry *direntry, struct inode *inode, void **cookie)
kfree(target_path);
return ERR_PTR(rc);
}
return *cookie = target_path;
set_delayed_call(done, kfree_link, target_path);
return target_path;
}

int
Expand Down
1 change: 0 additions & 1 deletion fs/coda/cnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ static inline int coda_fideq(struct CodaFid *fid1, struct CodaFid *fid2)
static const struct inode_operations coda_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.put_link = page_put_link,
.setattr = coda_setattr,
};

Expand Down
17 changes: 9 additions & 8 deletions fs/configfs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,31 +280,32 @@ static int configfs_getlink(struct dentry *dentry, char * path)
}

static const char *configfs_get_link(struct dentry *dentry,
struct inode *inode, void **cookie)
struct inode *inode,
struct delayed_call *done)
{
char *page;
char *body;
int error;

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

page = kzalloc(PAGE_SIZE, GFP_KERNEL);
if (!page)
body = kzalloc(PAGE_SIZE, GFP_KERNEL);
if (!body)
return ERR_PTR(-ENOMEM);

error = configfs_getlink(dentry, page);
error = configfs_getlink(dentry, body);
if (!error) {
return *cookie = page;
set_delayed_call(done, kfree_link, body);
return body;
}

kfree(page);
kfree(body);
return ERR_PTR(error);
}

const struct inode_operations configfs_symlink_inode_operations = {
.get_link = configfs_get_link,
.readlink = generic_readlink,
.put_link = kfree_put_link,
.setattr = configfs_setattr,
};

7 changes: 4 additions & 3 deletions fs/ecryptfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
}

static const char *ecryptfs_get_link(struct dentry *dentry,
struct inode *inode, void **cookie)
struct inode *inode,
struct delayed_call *done)
{
size_t len;
char *buf;
Expand All @@ -689,7 +690,8 @@ static const char *ecryptfs_get_link(struct dentry *dentry,
fsstack_copy_attr_atime(d_inode(dentry),
d_inode(ecryptfs_dentry_to_lower(dentry)));
buf[len] = '\0';
return *cookie = buf;
set_delayed_call(done, kfree_link, buf);
return buf;
}

/**
Expand Down Expand Up @@ -1102,7 +1104,6 @@ static int ecryptfs_removexattr(struct dentry *dentry, const char *name)
const struct inode_operations ecryptfs_symlink_iops = {
.readlink = generic_readlink,
.get_link = ecryptfs_get_link,
.put_link = kfree_put_link,
.permission = ecryptfs_permission,
.setattr = ecryptfs_setattr,
.getattr = ecryptfs_getattr_link,
Expand Down
1 change: 0 additions & 1 deletion fs/ext2/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
const struct inode_operations ext2_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.put_link = page_put_link,
.setattr = ext2_setattr,
#ifdef CONFIG_EXT2_FS_XATTR
.setxattr = generic_setxattr,
Expand Down
8 changes: 4 additions & 4 deletions fs/ext4/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

#ifdef CONFIG_EXT4_FS_ENCRYPTION
static const char *ext4_encrypted_get_link(struct dentry *dentry,
struct inode *inode, void **cookie)
struct inode *inode,
struct delayed_call *done)
{
struct page *cpage = NULL;
char *caddr, *paddr = NULL;
Expand Down Expand Up @@ -80,7 +81,8 @@ static const char *ext4_encrypted_get_link(struct dentry *dentry,
paddr[res] = '\0';
if (cpage)
page_cache_release(cpage);
return *cookie = paddr;
set_delayed_call(done, kfree_link, paddr);
return paddr;
errout:
if (cpage)
page_cache_release(cpage);
Expand All @@ -91,7 +93,6 @@ static const char *ext4_encrypted_get_link(struct dentry *dentry,
const struct inode_operations ext4_encrypted_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = ext4_encrypted_get_link,
.put_link = kfree_put_link,
.setattr = ext4_setattr,
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
Expand All @@ -103,7 +104,6 @@ const struct inode_operations ext4_encrypted_symlink_inode_operations = {
const struct inode_operations ext4_symlink_inode_operations = {
.readlink = generic_readlink,
.get_link = page_get_link,
.put_link = page_put_link,
.setattr = ext4_setattr,
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
Expand Down
Loading

0 comments on commit fceef39

Please sign in to comment.