Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 144811
b: refs/heads/master
c: a731d12
h: refs/heads/master
i:
  144809: 158f824
  144807: 989a6f4
v: v3
  • Loading branch information
Joel Becker authored and Al Viro committed May 9, 2009
1 parent e480bc4 commit 5bbffd1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 265e771e8197cdb22a1e2556663173fb62c9cd91
refs/heads/master: a731d12d6ddd1e703770cacb5dfecb155b03ee06
77 changes: 37 additions & 40 deletions trunk/fs/ocfs2/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <linux/slab.h>
#include <linux/pagemap.h>
#include <linux/utsname.h>
#include <linux/namei.h>

#define MLOG_MASK_PREFIX ML_NAMEI
#include <cluster/masklog.h>
Expand All @@ -54,26 +55,6 @@

#include "buffer_head_io.h"

static char *ocfs2_page_getlink(struct dentry * dentry,
struct page **ppage);
static char *ocfs2_fast_symlink_getlink(struct inode *inode,
struct buffer_head **bh);

/* get the link contents into pagecache */
static char *ocfs2_page_getlink(struct dentry * dentry,
struct page **ppage)
{
struct page * page;
struct address_space *mapping = dentry->d_inode->i_mapping;
page = read_mapping_page(mapping, 0, NULL);
if (IS_ERR(page))
goto sync_fail;
*ppage = page;
return kmap(page);

sync_fail:
return (char*)page;
}

static char *ocfs2_fast_symlink_getlink(struct inode *inode,
struct buffer_head **bh)
Expand Down Expand Up @@ -128,40 +109,55 @@ static int ocfs2_readlink(struct dentry *dentry,
return ret;
}

static void *ocfs2_follow_link(struct dentry *dentry,
struct nameidata *nd)
static void *ocfs2_fast_follow_link(struct dentry *dentry,
struct nameidata *nd)
{
int status;
char *link;
int status = 0;
int len;
char *target, *link = ERR_PTR(-ENOMEM);
struct inode *inode = dentry->d_inode;
struct page *page = NULL;
struct buffer_head *bh = NULL;
if (ocfs2_inode_is_fast_symlink(inode))
link = ocfs2_fast_symlink_getlink(inode, &bh);
else
link = ocfs2_page_getlink(dentry, &page);
if (IS_ERR(link)) {
status = PTR_ERR(link);

mlog_entry_void();

BUG_ON(!ocfs2_inode_is_fast_symlink(inode));
target = ocfs2_fast_symlink_getlink(inode, &bh);
if (IS_ERR(target)) {
status = PTR_ERR(target);
mlog_errno(status);
goto bail;
}

status = vfs_follow_link(nd, link);
/* Fast symlinks can't be large */
len = strlen(target);
link = kzalloc(len + 1, GFP_NOFS);
if (!link) {
status = -ENOMEM;
mlog_errno(status);
goto bail;
}

memcpy(link, target, len);
nd_set_link(nd, link);

bail:
if (page) {
kunmap(page);
page_cache_release(page);
}
brelse(bh);

return ERR_PTR(status);
mlog_exit(status);
return status ? ERR_PTR(status) : link;
}

static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
{
char *link = cookie;

kfree(link);
}

const struct inode_operations ocfs2_symlink_inode_operations = {
.readlink = page_readlink,
.follow_link = ocfs2_follow_link,
.follow_link = page_follow_link_light,
.put_link = page_put_link,
.getattr = ocfs2_getattr,
.setattr = ocfs2_setattr,
.setxattr = generic_setxattr,
Expand All @@ -171,7 +167,8 @@ const struct inode_operations ocfs2_symlink_inode_operations = {
};
const struct inode_operations ocfs2_fast_symlink_inode_operations = {
.readlink = ocfs2_readlink,
.follow_link = ocfs2_follow_link,
.follow_link = ocfs2_fast_follow_link,
.put_link = ocfs2_fast_put_link,
.getattr = ocfs2_getattr,
.setattr = ocfs2_setattr,
.setxattr = generic_setxattr,
Expand Down

0 comments on commit 5bbffd1

Please sign in to comment.