Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 262327
b: refs/heads/master
c: 69f07ec
h: refs/heads/master
i:
  262325: 62c15ee
  262323: b98eef7
  262319: 49b7f49
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Aug 4, 2011
1 parent 4734ee9 commit 6b707fc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 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: 6922c0c7abd387374255801f7739624867e8acad
refs/heads/master: 69f07ec938712b58755add82dd3d0b35f01317cc
11 changes: 3 additions & 8 deletions trunk/include/linux/shmem_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@

/* inode in-kernel data */

#define SHMEM_NR_DIRECT 16

#define SHMEM_SYMLINK_INLINE_LEN (SHMEM_NR_DIRECT * sizeof(swp_entry_t))

struct shmem_inode_info {
spinlock_t lock;
unsigned long flags;
unsigned long alloced; /* data pages alloced to file */
unsigned long swapped; /* subtotal assigned to swap */
struct shared_policy policy; /* NUMA memory alloc policy */
union {
swp_entry_t i_direct[SHMEM_NR_DIRECT]; /* first blocks */
char inline_symlink[SHMEM_SYMLINK_INLINE_LEN];
unsigned long swapped; /* subtotal assigned to swap */
char *symlink; /* unswappable short symlink */
};
struct shared_policy policy; /* NUMA memory alloc policy */
struct list_head swaplist; /* chain of maybes on swap */
struct list_head xattr_list; /* list of shmem_xattr */
struct inode vfs_inode;
Expand Down
31 changes: 18 additions & 13 deletions trunk/mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ static struct vfsmount *shm_mnt;
/* Pretend that each entry is of this size in directory's i_size */
#define BOGO_DIRENT_SIZE 20

/* Symlink up to this size is kmalloc'ed instead of using a swappable page */
#define SHORT_SYMLINK_LEN 128

struct shmem_xattr {
struct list_head list; /* anchored by shmem_inode_info->xattr_list */
char *name; /* xattr name */
Expand Down Expand Up @@ -585,7 +588,8 @@ static void shmem_evict_inode(struct inode *inode)
list_del_init(&info->swaplist);
mutex_unlock(&shmem_swaplist_mutex);
}
}
} else
kfree(info->symlink);

list_for_each_entry_safe(xattr, nxattr, &info->xattr_list, list) {
kfree(xattr->name);
Expand Down Expand Up @@ -1173,7 +1177,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode

#ifdef CONFIG_TMPFS
static const struct inode_operations shmem_symlink_inode_operations;
static const struct inode_operations shmem_symlink_inline_operations;
static const struct inode_operations shmem_short_symlink_operations;

static int
shmem_write_begin(struct file *file, struct address_space *mapping,
Expand Down Expand Up @@ -1638,10 +1642,13 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s

info = SHMEM_I(inode);
inode->i_size = len-1;
if (len <= SHMEM_SYMLINK_INLINE_LEN) {
/* do it inline */
memcpy(info->inline_symlink, symname, len);
inode->i_op = &shmem_symlink_inline_operations;
if (len <= SHORT_SYMLINK_LEN) {
info->symlink = kmemdup(symname, len, GFP_KERNEL);
if (!info->symlink) {
iput(inode);
return -ENOMEM;
}
inode->i_op = &shmem_short_symlink_operations;
} else {
error = shmem_getpage(inode, 0, &page, SGP_WRITE, NULL);
if (error) {
Expand All @@ -1664,9 +1671,9 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
return 0;
}

static void *shmem_follow_link_inline(struct dentry *dentry, struct nameidata *nd)
static void *shmem_follow_short_symlink(struct dentry *dentry, struct nameidata *nd)
{
nd_set_link(nd, SHMEM_I(dentry->d_inode)->inline_symlink);
nd_set_link(nd, SHMEM_I(dentry->d_inode)->symlink);
return NULL;
}

Expand Down Expand Up @@ -1914,9 +1921,9 @@ static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer, size_t size)
}
#endif /* CONFIG_TMPFS_XATTR */

static const struct inode_operations shmem_symlink_inline_operations = {
static const struct inode_operations shmem_short_symlink_operations = {
.readlink = generic_readlink,
.follow_link = shmem_follow_link_inline,
.follow_link = shmem_follow_short_symlink,
#ifdef CONFIG_TMPFS_XATTR
.setxattr = shmem_setxattr,
.getxattr = shmem_getxattr,
Expand Down Expand Up @@ -2259,10 +2266,8 @@ static void shmem_destroy_callback(struct rcu_head *head)

static void shmem_destroy_inode(struct inode *inode)
{
if ((inode->i_mode & S_IFMT) == S_IFREG) {
/* only struct inode is valid if it's an inline symlink */
if ((inode->i_mode & S_IFMT) == S_IFREG)
mpol_free_shared_policy(&SHMEM_I(inode)->policy);
}
call_rcu(&inode->i_rcu, shmem_destroy_callback);
}

Expand Down

0 comments on commit 6b707fc

Please sign in to comment.