Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (52 commits) init: Open /dev/console from rootfs mqueue: fix typo "failues" -> "failures" mqueue: only set error codes if they are really necessary mqueue: simplify do_open() error handling mqueue: apply mathematics distributivity on mq_bytes calculation mqueue: remove unneeded info->messages initialization mqueue: fix mq_open() file descriptor leak on user-space processes fix race in d_splice_alias() set S_DEAD on unlink() and non-directory rename() victims vfs: add NOFOLLOW flag to umount(2) get rid of ->mnt_parent in tomoyo/realpath hppfs can use existing proc_mnt, no need for do_kern_mount() in there Mirror MS_KERNMOUNT in ->mnt_flags get rid of useless vfsmount_lock use in put_mnt_ns() Take vfsmount_lock to fs/internal.h get rid of insanity with namespace roots in tomoyo take check for new events in namespace (guts of mounts_poll()) to namespace.c Don't mess with generic_permission() under ->d_lock in hpfs sanitize const/signedness for udf nilfs: sanitize const/signedness in dealing with ->d_name.name ... Fix up fairly trivial (famous last words...) conflicts in drivers/infiniband/core/uverbs_main.c and security/tomoyo/realpath.c
This commit is contained in:
commit
0f2cc4ecd8
73 changed files with 773 additions and 1080 deletions
|
|
@ -837,6 +837,9 @@ replicas continue to be exactly same.
|
|||
individual lists does not affect propagation or the way propagation
|
||||
tree is modified by operations.
|
||||
|
||||
All vfsmounts in a peer group have the same ->mnt_master. If it is
|
||||
non-NULL, they form a contiguous (ordered) segment of slave list.
|
||||
|
||||
A example propagation tree looks as shown in the figure below.
|
||||
[ NOTE: Though it looks like a forest, if we consider all the shared
|
||||
mounts as a conceptual entity called 'pnode', it becomes a tree]
|
||||
|
|
@ -874,8 +877,19 @@ replicas continue to be exactly same.
|
|||
|
||||
NOTE: The propagation tree is orthogonal to the mount tree.
|
||||
|
||||
8B Locking:
|
||||
|
||||
8B Algorithm:
|
||||
->mnt_share, ->mnt_slave, ->mnt_slave_list, ->mnt_master are protected
|
||||
by namespace_sem (exclusive for modifications, shared for reading).
|
||||
|
||||
Normally we have ->mnt_flags modifications serialized by vfsmount_lock.
|
||||
There are two exceptions: do_add_mount() and clone_mnt().
|
||||
The former modifies a vfsmount that has not been visible in any shared
|
||||
data structures yet.
|
||||
The latter holds namespace_sem and the only references to vfsmount
|
||||
are in lists that can't be traversed without namespace_sem.
|
||||
|
||||
8C Algorithm:
|
||||
|
||||
The crux of the implementation resides in rbind/move operation.
|
||||
|
||||
|
|
|
|||
|
|
@ -288,46 +288,30 @@ static int hypfs_fill_super(struct super_block *sb, void *data, int silent)
|
|||
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
|
||||
sb->s_magic = HYPFS_MAGIC;
|
||||
sb->s_op = &hypfs_s_ops;
|
||||
if (hypfs_parse_options(data, sb)) {
|
||||
rc = -EINVAL;
|
||||
goto err_alloc;
|
||||
}
|
||||
if (hypfs_parse_options(data, sb))
|
||||
return -EINVAL;
|
||||
root_inode = hypfs_make_inode(sb, S_IFDIR | 0755);
|
||||
if (!root_inode) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
}
|
||||
if (!root_inode)
|
||||
return -ENOMEM;
|
||||
root_inode->i_op = &simple_dir_inode_operations;
|
||||
root_inode->i_fop = &simple_dir_operations;
|
||||
root_dentry = d_alloc_root(root_inode);
|
||||
sb->s_root = root_dentry = d_alloc_root(root_inode);
|
||||
if (!root_dentry) {
|
||||
iput(root_inode);
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (MACHINE_IS_VM)
|
||||
rc = hypfs_vm_create_files(sb, root_dentry);
|
||||
else
|
||||
rc = hypfs_diag_create_files(sb, root_dentry);
|
||||
if (rc)
|
||||
goto err_tree;
|
||||
return rc;
|
||||
sbi->update_file = hypfs_create_update_file(sb, root_dentry);
|
||||
if (IS_ERR(sbi->update_file)) {
|
||||
rc = PTR_ERR(sbi->update_file);
|
||||
goto err_tree;
|
||||
}
|
||||
if (IS_ERR(sbi->update_file))
|
||||
return PTR_ERR(sbi->update_file);
|
||||
hypfs_update_update(sb);
|
||||
sb->s_root = root_dentry;
|
||||
pr_info("Hypervisor filesystem mounted\n");
|
||||
return 0;
|
||||
|
||||
err_tree:
|
||||
hypfs_delete_tree(root_dentry);
|
||||
d_genocide(root_dentry);
|
||||
dput(root_dentry);
|
||||
err_alloc:
|
||||
kfree(sbi);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int hypfs_get_super(struct file_system_type *fst, int flags,
|
||||
|
|
@ -340,12 +324,12 @@ static void hypfs_kill_super(struct super_block *sb)
|
|||
{
|
||||
struct hypfs_sb_info *sb_info = sb->s_fs_info;
|
||||
|
||||
if (sb->s_root) {
|
||||
if (sb->s_root)
|
||||
hypfs_delete_tree(sb->s_root);
|
||||
if (sb_info->update_file)
|
||||
hypfs_remove(sb_info->update_file);
|
||||
kfree(sb->s_fs_info);
|
||||
sb->s_fs_info = NULL;
|
||||
}
|
||||
kfree(sb->s_fs_info);
|
||||
sb->s_fs_info = NULL;
|
||||
kill_litter_super(sb);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ void mconsole_proc(struct mc_request *req)
|
|||
goto out;
|
||||
}
|
||||
|
||||
err = may_open(&nd.path, MAY_READ, FMODE_READ);
|
||||
err = may_open(&nd.path, MAY_READ, O_RDONLY);
|
||||
if (result) {
|
||||
mconsole_reply(req, "Failed to open file", 1, 0);
|
||||
path_put(&nd.path);
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ extern struct idr ib_uverbs_srq_idr;
|
|||
void idr_remove_uobj(struct idr *idp, struct ib_uobject *uobj);
|
||||
|
||||
struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
|
||||
int is_async, int *fd);
|
||||
int is_async);
|
||||
struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd);
|
||||
|
||||
void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
|
||||
|
|
|
|||
|
|
@ -301,10 +301,15 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
|
|||
|
||||
resp.num_comp_vectors = file->device->num_comp_vectors;
|
||||
|
||||
filp = ib_uverbs_alloc_event_file(file, 1, &resp.async_fd);
|
||||
ret = get_unused_fd();
|
||||
if (ret < 0)
|
||||
goto err_free;
|
||||
resp.async_fd = ret;
|
||||
|
||||
filp = ib_uverbs_alloc_event_file(file, 1);
|
||||
if (IS_ERR(filp)) {
|
||||
ret = PTR_ERR(filp);
|
||||
goto err_free;
|
||||
goto err_fd;
|
||||
}
|
||||
|
||||
if (copy_to_user((void __user *) (unsigned long) cmd.response,
|
||||
|
|
@ -332,9 +337,11 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
|
|||
return in_len;
|
||||
|
||||
err_file:
|
||||
put_unused_fd(resp.async_fd);
|
||||
fput(filp);
|
||||
|
||||
err_fd:
|
||||
put_unused_fd(resp.async_fd);
|
||||
|
||||
err_free:
|
||||
ibdev->dealloc_ucontext(ucontext);
|
||||
|
||||
|
|
@ -715,6 +722,7 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
|
|||
struct ib_uverbs_create_comp_channel cmd;
|
||||
struct ib_uverbs_create_comp_channel_resp resp;
|
||||
struct file *filp;
|
||||
int ret;
|
||||
|
||||
if (out_len < sizeof resp)
|
||||
return -ENOSPC;
|
||||
|
|
@ -722,9 +730,16 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
|
|||
if (copy_from_user(&cmd, buf, sizeof cmd))
|
||||
return -EFAULT;
|
||||
|
||||
filp = ib_uverbs_alloc_event_file(file, 0, &resp.fd);
|
||||
if (IS_ERR(filp))
|
||||
ret = get_unused_fd();
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
resp.fd = ret;
|
||||
|
||||
filp = ib_uverbs_alloc_event_file(file, 0);
|
||||
if (IS_ERR(filp)) {
|
||||
put_unused_fd(resp.fd);
|
||||
return PTR_ERR(filp);
|
||||
}
|
||||
|
||||
if (copy_to_user((void __user *) (unsigned long) cmd.response,
|
||||
&resp, sizeof resp)) {
|
||||
|
|
|
|||
|
|
@ -484,11 +484,10 @@ void ib_uverbs_event_handler(struct ib_event_handler *handler,
|
|||
}
|
||||
|
||||
struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
|
||||
int is_async, int *fd)
|
||||
int is_async)
|
||||
{
|
||||
struct ib_uverbs_event_file *ev_file;
|
||||
struct file *filp;
|
||||
int ret;
|
||||
|
||||
ev_file = kmalloc(sizeof *ev_file, GFP_KERNEL);
|
||||
if (!ev_file)
|
||||
|
|
@ -503,27 +502,12 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
|
|||
ev_file->is_async = is_async;
|
||||
ev_file->is_closed = 0;
|
||||
|
||||
*fd = get_unused_fd();
|
||||
if (*fd < 0) {
|
||||
ret = *fd;
|
||||
goto err;
|
||||
}
|
||||
|
||||
filp = anon_inode_getfile("[uverbs-event]", &uverbs_event_fops,
|
||||
filp = anon_inode_getfile("[infinibandevent]", &uverbs_event_fops,
|
||||
ev_file, O_RDONLY);
|
||||
if (!filp) {
|
||||
ret = -ENFILE;
|
||||
goto err_fd;
|
||||
}
|
||||
if (IS_ERR(filp))
|
||||
kfree(ev_file);
|
||||
|
||||
return filp;
|
||||
|
||||
err_fd:
|
||||
put_unused_fd(*fd);
|
||||
|
||||
err:
|
||||
kfree(ev_file);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1050,7 +1050,7 @@ static void invalidate_sub(struct fsg_lun *curlun)
|
|||
unsigned long rc;
|
||||
|
||||
rc = invalidate_mapping_pages(inode->i_mapping, 0, -1);
|
||||
VLDBG(curlun, "invalidate_inode_pages -> %ld\n", rc);
|
||||
VLDBG(curlun, "invalidate_mapping_pages -> %ld\n", rc);
|
||||
}
|
||||
|
||||
static int do_verify(struct fsg_common *common)
|
||||
|
|
|
|||
|
|
@ -1448,7 +1448,7 @@ static void invalidate_sub(struct fsg_lun *curlun)
|
|||
unsigned long rc;
|
||||
|
||||
rc = invalidate_mapping_pages(inode->i_mapping, 0, -1);
|
||||
VLDBG(curlun, "invalidate_inode_pages -> %ld\n", rc);
|
||||
VLDBG(curlun, "invalidate_mapping_pages -> %ld\n", rc);
|
||||
}
|
||||
|
||||
static int do_verify(struct fsg_dev *fsg)
|
||||
|
|
|
|||
|
|
@ -60,11 +60,6 @@ do { \
|
|||
current->pid, __func__, ##args); \
|
||||
} while (0)
|
||||
|
||||
struct rehash_entry {
|
||||
struct task_struct *task;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
/* Unified info structure. This is pointed to by both the dentry and
|
||||
inode structures. Each file in the filesystem has an instance of this
|
||||
structure. It holds a reference to the dentry, so dentries are never
|
||||
|
|
@ -81,7 +76,6 @@ struct autofs_info {
|
|||
|
||||
struct list_head active;
|
||||
int active_count;
|
||||
struct list_head rehash_list;
|
||||
|
||||
struct list_head expiring;
|
||||
|
||||
|
|
@ -104,7 +98,6 @@ struct autofs_info {
|
|||
#define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */
|
||||
#define AUTOFS_INF_MOUNTPOINT (1<<1) /* mountpoint status for direct expire */
|
||||
#define AUTOFS_INF_PENDING (1<<2) /* dentry pending mount */
|
||||
#define AUTOFS_INF_REHASH (1<<3) /* dentry in transit to ->lookup() */
|
||||
|
||||
struct autofs_wait_queue {
|
||||
wait_queue_head_t queue;
|
||||
|
|
|
|||
|
|
@ -544,10 +544,9 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
|
|||
goto out;
|
||||
devid = new_encode_dev(path.mnt->mnt_sb->s_dev);
|
||||
err = 0;
|
||||
if (path.dentry->d_inode &&
|
||||
path.mnt->mnt_root == path.dentry) {
|
||||
if (path.mnt->mnt_root == path.dentry) {
|
||||
err = 1;
|
||||
magic = path.dentry->d_inode->i_sb->s_magic;
|
||||
magic = path.mnt->mnt_sb->s_magic;
|
||||
}
|
||||
} else {
|
||||
dev_t dev = sbi->sb->s_dev;
|
||||
|
|
@ -560,10 +559,8 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
|
|||
|
||||
err = have_submounts(path.dentry);
|
||||
|
||||
if (path.mnt->mnt_mountpoint != path.mnt->mnt_root) {
|
||||
if (follow_down(&path))
|
||||
magic = path.mnt->mnt_sb->s_magic;
|
||||
}
|
||||
if (follow_down(&path))
|
||||
magic = path.mnt->mnt_sb->s_magic;
|
||||
}
|
||||
|
||||
param->ismountpoint.out.devid = devid;
|
||||
|
|
|
|||
|
|
@ -279,7 +279,6 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
|
|||
root->d_mounted--;
|
||||
}
|
||||
ino->flags |= AUTOFS_INF_EXPIRING;
|
||||
autofs4_add_expiring(root);
|
||||
init_completion(&ino->expire_complete);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
return root;
|
||||
|
|
@ -407,7 +406,6 @@ found:
|
|||
expired, (int)expired->d_name.len, expired->d_name.name);
|
||||
ino = autofs4_dentry_ino(expired);
|
||||
ino->flags |= AUTOFS_INF_EXPIRING;
|
||||
autofs4_add_expiring(expired);
|
||||
init_completion(&ino->expire_complete);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
spin_lock(&dcache_lock);
|
||||
|
|
@ -435,7 +433,7 @@ int autofs4_expire_wait(struct dentry *dentry)
|
|||
|
||||
DPRINTK("expire done status=%d", status);
|
||||
|
||||
if (d_unhashed(dentry) && IS_DEADDIR(dentry->d_inode))
|
||||
if (d_unhashed(dentry))
|
||||
return -EAGAIN;
|
||||
|
||||
return status;
|
||||
|
|
@ -475,7 +473,6 @@ int autofs4_expire_run(struct super_block *sb,
|
|||
spin_lock(&sbi->fs_lock);
|
||||
ino = autofs4_dentry_ino(dentry);
|
||||
ino->flags &= ~AUTOFS_INF_EXPIRING;
|
||||
autofs4_del_expiring(dentry);
|
||||
complete_all(&ino->expire_complete);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
|
||||
|
|
@ -506,7 +503,6 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
|
|||
ino->flags &= ~AUTOFS_INF_MOUNTPOINT;
|
||||
}
|
||||
ino->flags &= ~AUTOFS_INF_EXPIRING;
|
||||
autofs4_del_expiring(dentry);
|
||||
complete_all(&ino->expire_complete);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
dput(dentry);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
|
|||
ino->dentry = NULL;
|
||||
ino->size = 0;
|
||||
INIT_LIST_HEAD(&ino->active);
|
||||
INIT_LIST_HEAD(&ino->rehash_list);
|
||||
ino->active_count = 0;
|
||||
INIT_LIST_HEAD(&ino->expiring);
|
||||
atomic_set(&ino->count, 0);
|
||||
|
|
@ -97,63 +96,6 @@ void autofs4_free_ino(struct autofs_info *ino)
|
|||
kfree(ino);
|
||||
}
|
||||
|
||||
/*
|
||||
* Deal with the infamous "Busy inodes after umount ..." message.
|
||||
*
|
||||
* Clean up the dentry tree. This happens with autofs if the user
|
||||
* space program goes away due to a SIGKILL, SIGSEGV etc.
|
||||
*/
|
||||
static void autofs4_force_release(struct autofs_sb_info *sbi)
|
||||
{
|
||||
struct dentry *this_parent = sbi->sb->s_root;
|
||||
struct list_head *next;
|
||||
|
||||
if (!sbi->sb->s_root)
|
||||
return;
|
||||
|
||||
spin_lock(&dcache_lock);
|
||||
repeat:
|
||||
next = this_parent->d_subdirs.next;
|
||||
resume:
|
||||
while (next != &this_parent->d_subdirs) {
|
||||
struct dentry *dentry = list_entry(next, struct dentry, d_u.d_child);
|
||||
|
||||
/* Negative dentry - don`t care */
|
||||
if (!simple_positive(dentry)) {
|
||||
next = next->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!list_empty(&dentry->d_subdirs)) {
|
||||
this_parent = dentry;
|
||||
goto repeat;
|
||||
}
|
||||
|
||||
next = next->next;
|
||||
spin_unlock(&dcache_lock);
|
||||
|
||||
DPRINTK("dentry %p %.*s",
|
||||
dentry, (int)dentry->d_name.len, dentry->d_name.name);
|
||||
|
||||
dput(dentry);
|
||||
spin_lock(&dcache_lock);
|
||||
}
|
||||
|
||||
if (this_parent != sbi->sb->s_root) {
|
||||
struct dentry *dentry = this_parent;
|
||||
|
||||
next = this_parent->d_u.d_child.next;
|
||||
this_parent = this_parent->d_parent;
|
||||
spin_unlock(&dcache_lock);
|
||||
DPRINTK("parent dentry %p %.*s",
|
||||
dentry, (int)dentry->d_name.len, dentry->d_name.name);
|
||||
dput(dentry);
|
||||
spin_lock(&dcache_lock);
|
||||
goto resume;
|
||||
}
|
||||
spin_unlock(&dcache_lock);
|
||||
}
|
||||
|
||||
void autofs4_kill_sb(struct super_block *sb)
|
||||
{
|
||||
struct autofs_sb_info *sbi = autofs4_sbi(sb);
|
||||
|
|
@ -170,15 +112,12 @@ void autofs4_kill_sb(struct super_block *sb)
|
|||
/* Free wait queues, close pipe */
|
||||
autofs4_catatonic_mode(sbi);
|
||||
|
||||
/* Clean up and release dangling references */
|
||||
autofs4_force_release(sbi);
|
||||
|
||||
sb->s_fs_info = NULL;
|
||||
kfree(sbi);
|
||||
|
||||
out_kill_sb:
|
||||
DPRINTK("shutting down");
|
||||
kill_anon_super(sb);
|
||||
kill_litter_super(sb);
|
||||
}
|
||||
|
||||
static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt)
|
||||
|
|
|
|||
|
|
@ -104,99 +104,6 @@ static void autofs4_del_active(struct dentry *dentry)
|
|||
return;
|
||||
}
|
||||
|
||||
static void autofs4_add_rehash_entry(struct autofs_info *ino,
|
||||
struct rehash_entry *entry)
|
||||
{
|
||||
entry->task = current;
|
||||
INIT_LIST_HEAD(&entry->list);
|
||||
list_add(&entry->list, &ino->rehash_list);
|
||||
return;
|
||||
}
|
||||
|
||||
static void autofs4_remove_rehash_entry(struct autofs_info *ino)
|
||||
{
|
||||
struct list_head *head = &ino->rehash_list;
|
||||
struct rehash_entry *entry;
|
||||
list_for_each_entry(entry, head, list) {
|
||||
if (entry->task == current) {
|
||||
list_del(&entry->list);
|
||||
kfree(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void autofs4_remove_rehash_entrys(struct autofs_info *ino)
|
||||
{
|
||||
struct autofs_sb_info *sbi = ino->sbi;
|
||||
struct rehash_entry *entry, *next;
|
||||
struct list_head *head;
|
||||
|
||||
spin_lock(&sbi->fs_lock);
|
||||
spin_lock(&sbi->lookup_lock);
|
||||
if (!(ino->flags & AUTOFS_INF_REHASH)) {
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
return;
|
||||
}
|
||||
ino->flags &= ~AUTOFS_INF_REHASH;
|
||||
head = &ino->rehash_list;
|
||||
list_for_each_entry_safe(entry, next, head, list) {
|
||||
list_del(&entry->list);
|
||||
kfree(entry);
|
||||
}
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
dput(ino->dentry);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void autofs4_revalidate_drop(struct dentry *dentry,
|
||||
struct rehash_entry *entry)
|
||||
{
|
||||
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
|
||||
struct autofs_info *ino = autofs4_dentry_ino(dentry);
|
||||
/*
|
||||
* Add to the active list so we can pick this up in
|
||||
* ->lookup(). Also add an entry to a rehash list so
|
||||
* we know when there are no dentrys in flight so we
|
||||
* know when we can rehash the dentry.
|
||||
*/
|
||||
spin_lock(&sbi->lookup_lock);
|
||||
if (list_empty(&ino->active))
|
||||
list_add(&ino->active, &sbi->active_list);
|
||||
autofs4_add_rehash_entry(ino, entry);
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
if (!(ino->flags & AUTOFS_INF_REHASH)) {
|
||||
ino->flags |= AUTOFS_INF_REHASH;
|
||||
dget(dentry);
|
||||
spin_lock(&dentry->d_lock);
|
||||
__d_drop(dentry);
|
||||
spin_unlock(&dentry->d_lock);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void autofs4_revalidate_rehash(struct dentry *dentry)
|
||||
{
|
||||
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
|
||||
struct autofs_info *ino = autofs4_dentry_ino(dentry);
|
||||
if (ino->flags & AUTOFS_INF_REHASH) {
|
||||
spin_lock(&sbi->lookup_lock);
|
||||
autofs4_remove_rehash_entry(ino);
|
||||
if (list_empty(&ino->rehash_list)) {
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
ino->flags &= ~AUTOFS_INF_REHASH;
|
||||
d_rehash(dentry);
|
||||
dput(ino->dentry);
|
||||
} else
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static unsigned int autofs4_need_mount(unsigned int flags)
|
||||
{
|
||||
unsigned int res = 0;
|
||||
|
|
@ -236,7 +143,7 @@ out:
|
|||
return dcache_dir_open(inode, file);
|
||||
}
|
||||
|
||||
static int try_to_fill_dentry(struct dentry *dentry)
|
||||
static int try_to_fill_dentry(struct dentry *dentry, int flags)
|
||||
{
|
||||
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
|
||||
struct autofs_info *ino = autofs4_dentry_ino(dentry);
|
||||
|
|
@ -249,17 +156,55 @@ static int try_to_fill_dentry(struct dentry *dentry)
|
|||
* Wait for a pending mount, triggering one if there
|
||||
* isn't one already
|
||||
*/
|
||||
DPRINTK("waiting for mount name=%.*s",
|
||||
dentry->d_name.len, dentry->d_name.name);
|
||||
if (dentry->d_inode == NULL) {
|
||||
DPRINTK("waiting for mount name=%.*s",
|
||||
dentry->d_name.len, dentry->d_name.name);
|
||||
|
||||
status = autofs4_wait(sbi, dentry, NFY_MOUNT);
|
||||
status = autofs4_wait(sbi, dentry, NFY_MOUNT);
|
||||
|
||||
DPRINTK("mount done status=%d", status);
|
||||
DPRINTK("mount done status=%d", status);
|
||||
|
||||
/* Update expiry counter */
|
||||
ino->last_used = jiffies;
|
||||
/* Turn this into a real negative dentry? */
|
||||
if (status == -ENOENT) {
|
||||
spin_lock(&sbi->fs_lock);
|
||||
ino->flags &= ~AUTOFS_INF_PENDING;
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
return status;
|
||||
} else if (status) {
|
||||
/* Return a negative dentry, but leave it "pending" */
|
||||
return status;
|
||||
}
|
||||
/* Trigger mount for path component or follow link */
|
||||
} else if (ino->flags & AUTOFS_INF_PENDING ||
|
||||
autofs4_need_mount(flags) ||
|
||||
current->link_count) {
|
||||
DPRINTK("waiting for mount name=%.*s",
|
||||
dentry->d_name.len, dentry->d_name.name);
|
||||
|
||||
return status;
|
||||
spin_lock(&sbi->fs_lock);
|
||||
ino->flags |= AUTOFS_INF_PENDING;
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
status = autofs4_wait(sbi, dentry, NFY_MOUNT);
|
||||
|
||||
DPRINTK("mount done status=%d", status);
|
||||
|
||||
if (status) {
|
||||
spin_lock(&sbi->fs_lock);
|
||||
ino->flags &= ~AUTOFS_INF_PENDING;
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize expiry counter after successful mount */
|
||||
if (ino)
|
||||
ino->last_used = jiffies;
|
||||
|
||||
spin_lock(&sbi->fs_lock);
|
||||
ino->flags &= ~AUTOFS_INF_PENDING;
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* For autofs direct mounts the follow link triggers the mount */
|
||||
|
|
@ -313,16 +258,10 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
|
|||
*/
|
||||
if (ino->flags & AUTOFS_INF_PENDING ||
|
||||
(!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs))) {
|
||||
ino->flags |= AUTOFS_INF_PENDING;
|
||||
spin_unlock(&dcache_lock);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
|
||||
status = try_to_fill_dentry(dentry);
|
||||
|
||||
spin_lock(&sbi->fs_lock);
|
||||
ino->flags &= ~AUTOFS_INF_PENDING;
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
|
||||
status = try_to_fill_dentry(dentry, 0);
|
||||
if (status)
|
||||
goto out_error;
|
||||
|
||||
|
|
@ -361,47 +300,18 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
|
|||
{
|
||||
struct inode *dir = dentry->d_parent->d_inode;
|
||||
struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
|
||||
struct autofs_info *ino = autofs4_dentry_ino(dentry);
|
||||
struct rehash_entry *entry;
|
||||
int oz_mode = autofs4_oz_mode(sbi);
|
||||
int flags = nd ? nd->flags : 0;
|
||||
unsigned int mutex_aquired;
|
||||
int status = 1;
|
||||
|
||||
DPRINTK("name = %.*s oz_mode = %d",
|
||||
dentry->d_name.len, dentry->d_name.name, oz_mode);
|
||||
|
||||
/* Daemon never causes a mount to trigger */
|
||||
if (autofs4_oz_mode(sbi))
|
||||
return 1;
|
||||
|
||||
entry = kmalloc(sizeof(struct rehash_entry), GFP_KERNEL);
|
||||
if (!entry)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_aquired = mutex_trylock(&dir->i_mutex);
|
||||
|
||||
spin_lock(&sbi->fs_lock);
|
||||
spin_lock(&dcache_lock);
|
||||
/* Pending dentry */
|
||||
spin_lock(&sbi->fs_lock);
|
||||
if (autofs4_ispending(dentry)) {
|
||||
int status;
|
||||
|
||||
/*
|
||||
* We can only unhash and send this to ->lookup() if
|
||||
* the directory mutex is held over d_revalidate() and
|
||||
* ->lookup(). This prevents the VFS from incorrectly
|
||||
* seeing the dentry as non-existent.
|
||||
*/
|
||||
ino->flags |= AUTOFS_INF_PENDING;
|
||||
if (!mutex_aquired) {
|
||||
autofs4_revalidate_drop(dentry, entry);
|
||||
spin_unlock(&dcache_lock);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
return 0;
|
||||
}
|
||||
spin_unlock(&dcache_lock);
|
||||
/* The daemon never causes a mount to trigger */
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
mutex_unlock(&dir->i_mutex);
|
||||
kfree(entry);
|
||||
|
||||
if (oz_mode)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* If the directory has gone away due to an expire
|
||||
|
|
@ -415,82 +325,45 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
|
|||
* A zero status is success otherwise we have a
|
||||
* negative error code.
|
||||
*/
|
||||
status = try_to_fill_dentry(dentry);
|
||||
|
||||
spin_lock(&sbi->fs_lock);
|
||||
ino->flags &= ~AUTOFS_INF_PENDING;
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
|
||||
status = try_to_fill_dentry(dentry, flags);
|
||||
if (status == 0)
|
||||
return 1;
|
||||
|
||||
return status;
|
||||
}
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
|
||||
/* Negative dentry.. invalidate if "old" */
|
||||
if (dentry->d_inode == NULL)
|
||||
return 0;
|
||||
|
||||
/* Check for a non-mountpoint directory with no contents */
|
||||
spin_lock(&dcache_lock);
|
||||
if (S_ISDIR(dentry->d_inode->i_mode) &&
|
||||
!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
|
||||
DPRINTK("dentry=%p %.*s, emptydir",
|
||||
dentry, dentry->d_name.len, dentry->d_name.name);
|
||||
spin_unlock(&dcache_lock);
|
||||
|
||||
if (autofs4_need_mount(flags) || current->link_count) {
|
||||
int status;
|
||||
/* The daemon never causes a mount to trigger */
|
||||
if (oz_mode)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* We can only unhash and send this to ->lookup() if
|
||||
* the directory mutex is held over d_revalidate() and
|
||||
* ->lookup(). This prevents the VFS from incorrectly
|
||||
* seeing the dentry as non-existent.
|
||||
*/
|
||||
ino->flags |= AUTOFS_INF_PENDING;
|
||||
if (!mutex_aquired) {
|
||||
autofs4_revalidate_drop(dentry, entry);
|
||||
spin_unlock(&dcache_lock);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
return 0;
|
||||
}
|
||||
spin_unlock(&dcache_lock);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
mutex_unlock(&dir->i_mutex);
|
||||
kfree(entry);
|
||||
/*
|
||||
* A zero status is success otherwise we have a
|
||||
* negative error code.
|
||||
*/
|
||||
status = try_to_fill_dentry(dentry, flags);
|
||||
if (status == 0)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* A zero status is success otherwise we have a
|
||||
* negative error code.
|
||||
*/
|
||||
status = try_to_fill_dentry(dentry);
|
||||
|
||||
spin_lock(&sbi->fs_lock);
|
||||
ino->flags &= ~AUTOFS_INF_PENDING;
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
|
||||
if (status == 0)
|
||||
return 1;
|
||||
|
||||
return status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
spin_unlock(&dcache_lock);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
|
||||
if (mutex_aquired)
|
||||
mutex_unlock(&dir->i_mutex);
|
||||
|
||||
kfree(entry);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void autofs4_free_rehash_entrys(struct autofs_info *inf)
|
||||
{
|
||||
struct list_head *head = &inf->rehash_list;
|
||||
struct rehash_entry *entry, *next;
|
||||
list_for_each_entry_safe(entry, next, head, list) {
|
||||
list_del(&entry->list);
|
||||
kfree(entry);
|
||||
}
|
||||
}
|
||||
|
||||
void autofs4_dentry_release(struct dentry *de)
|
||||
{
|
||||
struct autofs_info *inf;
|
||||
|
|
@ -509,8 +382,6 @@ void autofs4_dentry_release(struct dentry *de)
|
|||
list_del(&inf->active);
|
||||
if (!list_empty(&inf->expiring))
|
||||
list_del(&inf->expiring);
|
||||
if (!list_empty(&inf->rehash_list))
|
||||
autofs4_free_rehash_entrys(inf);
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
}
|
||||
|
||||
|
|
@ -543,7 +414,6 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry)
|
|||
const unsigned char *str = name->name;
|
||||
struct list_head *p, *head;
|
||||
|
||||
restart:
|
||||
spin_lock(&dcache_lock);
|
||||
spin_lock(&sbi->lookup_lock);
|
||||
head = &sbi->active_list;
|
||||
|
|
@ -561,19 +431,6 @@ restart:
|
|||
if (atomic_read(&active->d_count) == 0)
|
||||
goto next;
|
||||
|
||||
if (active->d_inode && IS_DEADDIR(active->d_inode)) {
|
||||
if (!list_empty(&ino->rehash_list)) {
|
||||
dget(active);
|
||||
spin_unlock(&active->d_lock);
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
spin_unlock(&dcache_lock);
|
||||
autofs4_remove_rehash_entrys(ino);
|
||||
dput(active);
|
||||
goto restart;
|
||||
}
|
||||
goto next;
|
||||
}
|
||||
|
||||
qstr = &active->d_name;
|
||||
|
||||
if (active->d_name.hash != hash)
|
||||
|
|
@ -586,11 +443,13 @@ restart:
|
|||
if (memcmp(qstr->name, str, len))
|
||||
goto next;
|
||||
|
||||
dget(active);
|
||||
spin_unlock(&active->d_lock);
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
spin_unlock(&dcache_lock);
|
||||
return active;
|
||||
if (d_unhashed(active)) {
|
||||
dget(active);
|
||||
spin_unlock(&active->d_lock);
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
spin_unlock(&dcache_lock);
|
||||
return active;
|
||||
}
|
||||
next:
|
||||
spin_unlock(&active->d_lock);
|
||||
}
|
||||
|
|
@ -639,11 +498,13 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
|
|||
if (memcmp(qstr->name, str, len))
|
||||
goto next;
|
||||
|
||||
dget(expiring);
|
||||
spin_unlock(&expiring->d_lock);
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
spin_unlock(&dcache_lock);
|
||||
return expiring;
|
||||
if (d_unhashed(expiring)) {
|
||||
dget(expiring);
|
||||
spin_unlock(&expiring->d_lock);
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
spin_unlock(&dcache_lock);
|
||||
return expiring;
|
||||
}
|
||||
next:
|
||||
spin_unlock(&expiring->d_lock);
|
||||
}
|
||||
|
|
@ -653,48 +514,6 @@ next:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct autofs_info *init_new_dentry(struct autofs_sb_info *sbi,
|
||||
struct dentry *dentry, int oz_mode)
|
||||
{
|
||||
struct autofs_info *ino;
|
||||
|
||||
/*
|
||||
* Mark the dentry incomplete but don't hash it. We do this
|
||||
* to serialize our inode creation operations (symlink and
|
||||
* mkdir) which prevents deadlock during the callback to
|
||||
* the daemon. Subsequent user space lookups for the same
|
||||
* dentry are placed on the wait queue while the daemon
|
||||
* itself is allowed passage unresticted so the create
|
||||
* operation itself can then hash the dentry. Finally,
|
||||
* we check for the hashed dentry and return the newly
|
||||
* hashed dentry.
|
||||
*/
|
||||
dentry->d_op = &autofs4_root_dentry_operations;
|
||||
|
||||
/*
|
||||
* And we need to ensure that the same dentry is used for
|
||||
* all following lookup calls until it is hashed so that
|
||||
* the dentry flags are persistent throughout the request.
|
||||
*/
|
||||
ino = autofs4_init_ino(NULL, sbi, 0555);
|
||||
if (!ino)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
dentry->d_fsdata = ino;
|
||||
ino->dentry = dentry;
|
||||
|
||||
/*
|
||||
* Only set the mount pending flag for new dentrys not created
|
||||
* by the daemon.
|
||||
*/
|
||||
if (!oz_mode)
|
||||
ino->flags |= AUTOFS_INF_PENDING;
|
||||
|
||||
d_instantiate(dentry, NULL);
|
||||
|
||||
return ino;
|
||||
}
|
||||
|
||||
/* Lookups in the root directory */
|
||||
static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
|
||||
{
|
||||
|
|
@ -702,7 +521,6 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
|
|||
struct autofs_info *ino;
|
||||
struct dentry *expiring, *active;
|
||||
int oz_mode;
|
||||
int status = 0;
|
||||
|
||||
DPRINTK("name = %.*s",
|
||||
dentry->d_name.len, dentry->d_name.name);
|
||||
|
|
@ -717,26 +535,44 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
|
|||
DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d",
|
||||
current->pid, task_pgrp_nr(current), sbi->catatonic, oz_mode);
|
||||
|
||||
spin_lock(&sbi->fs_lock);
|
||||
active = autofs4_lookup_active(dentry);
|
||||
if (active) {
|
||||
dentry = active;
|
||||
ino = autofs4_dentry_ino(dentry);
|
||||
/* If this came from revalidate, rehash it */
|
||||
autofs4_revalidate_rehash(dentry);
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
} else {
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
ino = init_new_dentry(sbi, dentry, oz_mode);
|
||||
if (IS_ERR(ino))
|
||||
return (struct dentry *) ino;
|
||||
/*
|
||||
* Mark the dentry incomplete but don't hash it. We do this
|
||||
* to serialize our inode creation operations (symlink and
|
||||
* mkdir) which prevents deadlock during the callback to
|
||||
* the daemon. Subsequent user space lookups for the same
|
||||
* dentry are placed on the wait queue while the daemon
|
||||
* itself is allowed passage unresticted so the create
|
||||
* operation itself can then hash the dentry. Finally,
|
||||
* we check for the hashed dentry and return the newly
|
||||
* hashed dentry.
|
||||
*/
|
||||
dentry->d_op = &autofs4_root_dentry_operations;
|
||||
|
||||
/*
|
||||
* And we need to ensure that the same dentry is used for
|
||||
* all following lookup calls until it is hashed so that
|
||||
* the dentry flags are persistent throughout the request.
|
||||
*/
|
||||
ino = autofs4_init_ino(NULL, sbi, 0555);
|
||||
if (!ino)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
dentry->d_fsdata = ino;
|
||||
ino->dentry = dentry;
|
||||
|
||||
autofs4_add_active(dentry);
|
||||
|
||||
d_instantiate(dentry, NULL);
|
||||
}
|
||||
|
||||
autofs4_add_active(dentry);
|
||||
|
||||
if (!oz_mode) {
|
||||
expiring = autofs4_lookup_expiring(dentry);
|
||||
mutex_unlock(&dir->i_mutex);
|
||||
expiring = autofs4_lookup_expiring(dentry);
|
||||
if (expiring) {
|
||||
/*
|
||||
* If we are racing with expire the request might not
|
||||
|
|
@ -744,22 +580,23 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
|
|||
* so it must have been successful, so just wait for it.
|
||||
*/
|
||||
autofs4_expire_wait(expiring);
|
||||
autofs4_del_expiring(expiring);
|
||||
dput(expiring);
|
||||
}
|
||||
status = try_to_fill_dentry(dentry);
|
||||
mutex_lock(&dir->i_mutex);
|
||||
|
||||
spin_lock(&sbi->fs_lock);
|
||||
ino->flags &= ~AUTOFS_INF_PENDING;
|
||||
ino->flags |= AUTOFS_INF_PENDING;
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
if (dentry->d_op && dentry->d_op->d_revalidate)
|
||||
(dentry->d_op->d_revalidate)(dentry, nd);
|
||||
mutex_lock(&dir->i_mutex);
|
||||
}
|
||||
|
||||
autofs4_del_active(dentry);
|
||||
|
||||
/*
|
||||
* If we had a mount fail, check if we had to handle
|
||||
* If we are still pending, check if we had to handle
|
||||
* a signal. If so we can force a restart..
|
||||
*/
|
||||
if (status) {
|
||||
if (ino->flags & AUTOFS_INF_PENDING) {
|
||||
/* See if we were interrupted */
|
||||
if (signal_pending(current)) {
|
||||
sigset_t *sigset = ¤t->pending.signal;
|
||||
|
|
@ -771,46 +608,43 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
|
|||
return ERR_PTR(-ERESTARTNOINTR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* User space can (and has done in the past) remove and re-create
|
||||
* this directory during the callback. This can leave us with an
|
||||
* unhashed dentry, but a successful mount! So we need to
|
||||
* perform another cached lookup in case the dentry now exists.
|
||||
*/
|
||||
if (!oz_mode && !have_submounts(dentry)) {
|
||||
struct dentry *new;
|
||||
new = d_lookup(dentry->d_parent, &dentry->d_name);
|
||||
if (new) {
|
||||
if (active)
|
||||
dput(active);
|
||||
return new;
|
||||
} else {
|
||||
if (!status)
|
||||
status = -ENOENT;
|
||||
if (!oz_mode) {
|
||||
spin_lock(&sbi->fs_lock);
|
||||
ino->flags &= ~AUTOFS_INF_PENDING;
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If we had a mount failure, return status to user space.
|
||||
* If the mount succeeded and we used a dentry from the active queue
|
||||
* return it.
|
||||
* If this dentry is unhashed, then we shouldn't honour this
|
||||
* lookup. Returning ENOENT here doesn't do the right thing
|
||||
* for all system calls, but it should be OK for the operations
|
||||
* we permit from an autofs.
|
||||
*/
|
||||
if (status) {
|
||||
dentry = ERR_PTR(status);
|
||||
if (!oz_mode && d_unhashed(dentry)) {
|
||||
/*
|
||||
* A user space application can (and has done in the past)
|
||||
* remove and re-create this directory during the callback.
|
||||
* This can leave us with an unhashed dentry, but a
|
||||
* successful mount! So we need to perform another
|
||||
* cached lookup in case the dentry now exists.
|
||||
*/
|
||||
struct dentry *parent = dentry->d_parent;
|
||||
struct dentry *new = d_lookup(parent, &dentry->d_name);
|
||||
if (new != NULL)
|
||||
dentry = new;
|
||||
else
|
||||
dentry = ERR_PTR(-ENOENT);
|
||||
|
||||
if (active)
|
||||
dput(active);
|
||||
|
||||
return dentry;
|
||||
} else {
|
||||
/*
|
||||
* Valid successful mount, return active dentry or NULL
|
||||
* for a new dentry.
|
||||
*/
|
||||
if (active)
|
||||
return active;
|
||||
}
|
||||
|
||||
if (active)
|
||||
return active;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -834,6 +668,8 @@ static int autofs4_dir_symlink(struct inode *dir,
|
|||
if (!ino)
|
||||
return -ENOMEM;
|
||||
|
||||
autofs4_del_active(dentry);
|
||||
|
||||
ino->size = strlen(symname);
|
||||
cp = kmalloc(ino->size + 1, GFP_KERNEL);
|
||||
if (!cp) {
|
||||
|
|
@ -910,6 +746,7 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
|
|||
dir->i_mtime = CURRENT_TIME;
|
||||
|
||||
spin_lock(&dcache_lock);
|
||||
autofs4_add_expiring(dentry);
|
||||
spin_lock(&dentry->d_lock);
|
||||
__d_drop(dentry);
|
||||
spin_unlock(&dentry->d_lock);
|
||||
|
|
@ -935,6 +772,7 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
|
|||
spin_unlock(&dcache_lock);
|
||||
return -ENOTEMPTY;
|
||||
}
|
||||
autofs4_add_expiring(dentry);
|
||||
spin_lock(&dentry->d_lock);
|
||||
__d_drop(dentry);
|
||||
spin_unlock(&dentry->d_lock);
|
||||
|
|
@ -972,6 +810,8 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
|
|||
if (!ino)
|
||||
return -ENOMEM;
|
||||
|
||||
autofs4_del_active(dentry);
|
||||
|
||||
inode = autofs4_get_inode(dir->i_sb, ino);
|
||||
if (!inode) {
|
||||
if (!dentry->d_fsdata)
|
||||
|
|
|
|||
|
|
@ -2289,9 +2289,9 @@ cifs_oplock_break(struct slow_work *work)
|
|||
if (inode && S_ISREG(inode->i_mode)) {
|
||||
#ifdef CONFIG_CIFS_EXPERIMENTAL
|
||||
if (cinode->clientCanCacheAll == 0)
|
||||
break_lease(inode, FMODE_READ);
|
||||
break_lease(inode, O_RDONLY);
|
||||
else if (cinode->clientCanCacheRead == 0)
|
||||
break_lease(inode, FMODE_WRITE);
|
||||
break_lease(inode, O_WRONLY);
|
||||
#endif
|
||||
rc = filemap_fdatawrite(inode->i_mapping);
|
||||
if (cinode->clientCanCacheRead == 0) {
|
||||
|
|
|
|||
70
fs/dcache.c
70
fs/dcache.c
|
|
@ -257,6 +257,7 @@ kill_it:
|
|||
if (dentry)
|
||||
goto repeat;
|
||||
}
|
||||
EXPORT_SYMBOL(dput);
|
||||
|
||||
/**
|
||||
* d_invalidate - invalidate a dentry
|
||||
|
|
@ -314,6 +315,7 @@ int d_invalidate(struct dentry * dentry)
|
|||
spin_unlock(&dcache_lock);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(d_invalidate);
|
||||
|
||||
/* This should be called _only_ with dcache_lock held */
|
||||
|
||||
|
|
@ -328,6 +330,7 @@ struct dentry * dget_locked(struct dentry *dentry)
|
|||
{
|
||||
return __dget_locked(dentry);
|
||||
}
|
||||
EXPORT_SYMBOL(dget_locked);
|
||||
|
||||
/**
|
||||
* d_find_alias - grab a hashed alias of inode
|
||||
|
|
@ -384,6 +387,7 @@ struct dentry * d_find_alias(struct inode *inode)
|
|||
}
|
||||
return de;
|
||||
}
|
||||
EXPORT_SYMBOL(d_find_alias);
|
||||
|
||||
/*
|
||||
* Try to kill dentries associated with this inode.
|
||||
|
|
@ -408,6 +412,7 @@ restart:
|
|||
}
|
||||
spin_unlock(&dcache_lock);
|
||||
}
|
||||
EXPORT_SYMBOL(d_prune_aliases);
|
||||
|
||||
/*
|
||||
* Throw away a dentry - free the inode, dput the parent. This requires that
|
||||
|
|
@ -610,6 +615,7 @@ void shrink_dcache_sb(struct super_block * sb)
|
|||
{
|
||||
__shrink_dcache_sb(sb, NULL, 0);
|
||||
}
|
||||
EXPORT_SYMBOL(shrink_dcache_sb);
|
||||
|
||||
/*
|
||||
* destroy a single subtree of dentries for unmount
|
||||
|
|
@ -792,6 +798,7 @@ positive:
|
|||
spin_unlock(&dcache_lock);
|
||||
return 1;
|
||||
}
|
||||
EXPORT_SYMBOL(have_submounts);
|
||||
|
||||
/*
|
||||
* Search the dentry child list for the specified parent,
|
||||
|
|
@ -876,6 +883,7 @@ void shrink_dcache_parent(struct dentry * parent)
|
|||
while ((found = select_parent(parent)) != 0)
|
||||
__shrink_dcache_sb(sb, &found, 0);
|
||||
}
|
||||
EXPORT_SYMBOL(shrink_dcache_parent);
|
||||
|
||||
/*
|
||||
* Scan `nr' dentries and return the number which remain.
|
||||
|
|
@ -968,6 +976,7 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
|
|||
|
||||
return dentry;
|
||||
}
|
||||
EXPORT_SYMBOL(d_alloc);
|
||||
|
||||
struct dentry *d_alloc_name(struct dentry *parent, const char *name)
|
||||
{
|
||||
|
|
@ -1012,6 +1021,7 @@ void d_instantiate(struct dentry *entry, struct inode * inode)
|
|||
spin_unlock(&dcache_lock);
|
||||
security_d_instantiate(entry, inode);
|
||||
}
|
||||
EXPORT_SYMBOL(d_instantiate);
|
||||
|
||||
/**
|
||||
* d_instantiate_unique - instantiate a non-aliased dentry
|
||||
|
|
@ -1108,6 +1118,7 @@ struct dentry * d_alloc_root(struct inode * root_inode)
|
|||
}
|
||||
return res;
|
||||
}
|
||||
EXPORT_SYMBOL(d_alloc_root);
|
||||
|
||||
static inline struct hlist_head *d_hash(struct dentry *parent,
|
||||
unsigned long hash)
|
||||
|
|
@ -1211,7 +1222,6 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
|
|||
BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED));
|
||||
spin_unlock(&dcache_lock);
|
||||
security_d_instantiate(new, inode);
|
||||
d_rehash(dentry);
|
||||
d_move(new, dentry);
|
||||
iput(inode);
|
||||
} else {
|
||||
|
|
@ -1225,6 +1235,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
|
|||
d_add(dentry, inode);
|
||||
return new;
|
||||
}
|
||||
EXPORT_SYMBOL(d_splice_alias);
|
||||
|
||||
/**
|
||||
* d_add_ci - lookup or allocate new dentry with case-exact name
|
||||
|
|
@ -1314,6 +1325,7 @@ err_out:
|
|||
iput(inode);
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
EXPORT_SYMBOL(d_add_ci);
|
||||
|
||||
/**
|
||||
* d_lookup - search for a dentry
|
||||
|
|
@ -1357,6 +1369,7 @@ struct dentry * d_lookup(struct dentry * parent, struct qstr * name)
|
|||
} while (read_seqretry(&rename_lock, seq));
|
||||
return dentry;
|
||||
}
|
||||
EXPORT_SYMBOL(d_lookup);
|
||||
|
||||
struct dentry * __d_lookup(struct dentry * parent, struct qstr * name)
|
||||
{
|
||||
|
|
@ -1483,6 +1496,7 @@ int d_validate(struct dentry *dentry, struct dentry *dparent)
|
|||
out:
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(d_validate);
|
||||
|
||||
/*
|
||||
* When a file is deleted, we have two options:
|
||||
|
|
@ -1528,6 +1542,7 @@ void d_delete(struct dentry * dentry)
|
|||
|
||||
fsnotify_nameremove(dentry, isdir);
|
||||
}
|
||||
EXPORT_SYMBOL(d_delete);
|
||||
|
||||
static void __d_rehash(struct dentry * entry, struct hlist_head *list)
|
||||
{
|
||||
|
|
@ -1556,6 +1571,7 @@ void d_rehash(struct dentry * entry)
|
|||
spin_unlock(&entry->d_lock);
|
||||
spin_unlock(&dcache_lock);
|
||||
}
|
||||
EXPORT_SYMBOL(d_rehash);
|
||||
|
||||
/*
|
||||
* When switching names, the actual string doesn't strictly have to
|
||||
|
|
@ -1702,6 +1718,7 @@ void d_move(struct dentry * dentry, struct dentry * target)
|
|||
d_move_locked(dentry, target);
|
||||
spin_unlock(&dcache_lock);
|
||||
}
|
||||
EXPORT_SYMBOL(d_move);
|
||||
|
||||
/**
|
||||
* d_ancestor - search for an ancestor
|
||||
|
|
@ -1868,6 +1885,7 @@ shouldnt_be_hashed:
|
|||
spin_unlock(&dcache_lock);
|
||||
BUG();
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(d_materialise_unique);
|
||||
|
||||
static int prepend(char **buffer, int *buflen, const char *str, int namelen)
|
||||
{
|
||||
|
|
@ -2005,6 +2023,7 @@ char *d_path(const struct path *path, char *buf, int buflen)
|
|||
path_put(&root);
|
||||
return res;
|
||||
}
|
||||
EXPORT_SYMBOL(d_path);
|
||||
|
||||
/*
|
||||
* Helper function for dentry_operations.d_dname() members
|
||||
|
|
@ -2171,6 +2190,30 @@ int is_subdir(struct dentry *new_dentry, struct dentry *old_dentry)
|
|||
return result;
|
||||
}
|
||||
|
||||
int path_is_under(struct path *path1, struct path *path2)
|
||||
{
|
||||
struct vfsmount *mnt = path1->mnt;
|
||||
struct dentry *dentry = path1->dentry;
|
||||
int res;
|
||||
spin_lock(&vfsmount_lock);
|
||||
if (mnt != path2->mnt) {
|
||||
for (;;) {
|
||||
if (mnt->mnt_parent == mnt) {
|
||||
spin_unlock(&vfsmount_lock);
|
||||
return 0;
|
||||
}
|
||||
if (mnt->mnt_parent == path2->mnt)
|
||||
break;
|
||||
mnt = mnt->mnt_parent;
|
||||
}
|
||||
dentry = mnt->mnt_mountpoint;
|
||||
}
|
||||
res = is_subdir(dentry, path2->dentry);
|
||||
spin_unlock(&vfsmount_lock);
|
||||
return res;
|
||||
}
|
||||
EXPORT_SYMBOL(path_is_under);
|
||||
|
||||
void d_genocide(struct dentry *root)
|
||||
{
|
||||
struct dentry *this_parent = root;
|
||||
|
|
@ -2228,6 +2271,7 @@ ino_t find_inode_number(struct dentry *dir, struct qstr *name)
|
|||
}
|
||||
return ino;
|
||||
}
|
||||
EXPORT_SYMBOL(find_inode_number);
|
||||
|
||||
static __initdata unsigned long dhash_entries;
|
||||
static int __init set_dhash_entries(char *str)
|
||||
|
|
@ -2297,6 +2341,7 @@ static void __init dcache_init(void)
|
|||
|
||||
/* SLAB cache for __getname() consumers */
|
||||
struct kmem_cache *names_cachep __read_mostly;
|
||||
EXPORT_SYMBOL(names_cachep);
|
||||
|
||||
EXPORT_SYMBOL(d_genocide);
|
||||
|
||||
|
|
@ -2326,26 +2371,3 @@ void __init vfs_caches_init(unsigned long mempages)
|
|||
bdev_cache_init();
|
||||
chrdev_init();
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(d_alloc);
|
||||
EXPORT_SYMBOL(d_alloc_root);
|
||||
EXPORT_SYMBOL(d_delete);
|
||||
EXPORT_SYMBOL(d_find_alias);
|
||||
EXPORT_SYMBOL(d_instantiate);
|
||||
EXPORT_SYMBOL(d_invalidate);
|
||||
EXPORT_SYMBOL(d_lookup);
|
||||
EXPORT_SYMBOL(d_move);
|
||||
EXPORT_SYMBOL_GPL(d_materialise_unique);
|
||||
EXPORT_SYMBOL(d_path);
|
||||
EXPORT_SYMBOL(d_prune_aliases);
|
||||
EXPORT_SYMBOL(d_rehash);
|
||||
EXPORT_SYMBOL(d_splice_alias);
|
||||
EXPORT_SYMBOL(d_add_ci);
|
||||
EXPORT_SYMBOL(d_validate);
|
||||
EXPORT_SYMBOL(dget_locked);
|
||||
EXPORT_SYMBOL(dput);
|
||||
EXPORT_SYMBOL(find_inode_number);
|
||||
EXPORT_SYMBOL(have_submounts);
|
||||
EXPORT_SYMBOL(names_cachep);
|
||||
EXPORT_SYMBOL(shrink_dcache_parent);
|
||||
EXPORT_SYMBOL(shrink_dcache_sb);
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
|
|||
}
|
||||
d_move(old_dentry, dentry);
|
||||
fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name,
|
||||
old_dentry->d_name.name, S_ISDIR(old_dentry->d_inode->i_mode),
|
||||
S_ISDIR(old_dentry->d_inode->i_mode),
|
||||
NULL, old_dentry);
|
||||
fsnotify_oldname_free(old_name);
|
||||
unlock_rename(new_dir, old_dir);
|
||||
|
|
|
|||
|
|
@ -116,11 +116,9 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
|
|||
* devices or filesystem images.
|
||||
*/
|
||||
memset(buf, 0, sizeof(buf));
|
||||
path.mnt = mnt->mnt_parent;
|
||||
path.dentry = mnt->mnt_mountpoint;
|
||||
path_get(&path);
|
||||
path.mnt = mnt;
|
||||
path.dentry = mnt->mnt_root;
|
||||
cp = d_path(&path, buf, sizeof(buf));
|
||||
path_put(&path);
|
||||
if (!IS_ERR(cp)) {
|
||||
memcpy(sbi->s_es->s_last_mounted, cp,
|
||||
sizeof(sbi->s_es->s_last_mounted));
|
||||
|
|
|
|||
|
|
@ -975,103 +975,12 @@ out:
|
|||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* gfs2_readlinki - return the contents of a symlink
|
||||
* @ip: the symlink's inode
|
||||
* @buf: a pointer to the buffer to be filled
|
||||
* @len: a pointer to the length of @buf
|
||||
*
|
||||
* If @buf is too small, a piece of memory is kmalloc()ed and needs
|
||||
* to be freed by the caller.
|
||||
*
|
||||
* Returns: errno
|
||||
*/
|
||||
|
||||
static int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len)
|
||||
{
|
||||
struct gfs2_holder i_gh;
|
||||
struct buffer_head *dibh;
|
||||
unsigned int x;
|
||||
int error;
|
||||
|
||||
gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh);
|
||||
error = gfs2_glock_nq(&i_gh);
|
||||
if (error) {
|
||||
gfs2_holder_uninit(&i_gh);
|
||||
return error;
|
||||
}
|
||||
|
||||
if (!ip->i_disksize) {
|
||||
gfs2_consist_inode(ip);
|
||||
error = -EIO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
error = gfs2_meta_inode_buffer(ip, &dibh);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
x = ip->i_disksize + 1;
|
||||
if (x > *len) {
|
||||
*buf = kmalloc(x, GFP_NOFS);
|
||||
if (!*buf) {
|
||||
error = -ENOMEM;
|
||||
goto out_brelse;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(*buf, dibh->b_data + sizeof(struct gfs2_dinode), x);
|
||||
*len = x;
|
||||
|
||||
out_brelse:
|
||||
brelse(dibh);
|
||||
out:
|
||||
gfs2_glock_dq_uninit(&i_gh);
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* gfs2_readlink - Read the value of a symlink
|
||||
* @dentry: the symlink
|
||||
* @buf: the buffer to read the symlink data into
|
||||
* @size: the size of the buffer
|
||||
*
|
||||
* Returns: errno
|
||||
*/
|
||||
|
||||
static int gfs2_readlink(struct dentry *dentry, char __user *user_buf,
|
||||
int user_size)
|
||||
{
|
||||
struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
|
||||
char array[GFS2_FAST_NAME_SIZE], *buf = array;
|
||||
unsigned int len = GFS2_FAST_NAME_SIZE;
|
||||
int error;
|
||||
|
||||
error = gfs2_readlinki(ip, &buf, &len);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (user_size > len - 1)
|
||||
user_size = len - 1;
|
||||
|
||||
if (copy_to_user(user_buf, buf, user_size))
|
||||
error = -EFAULT;
|
||||
else
|
||||
error = user_size;
|
||||
|
||||
if (buf != array)
|
||||
kfree(buf);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* gfs2_follow_link - Follow a symbolic link
|
||||
* @dentry: The dentry of the link
|
||||
* @nd: Data that we pass to vfs_follow_link()
|
||||
*
|
||||
* This can handle symlinks of any size. It is optimised for symlinks
|
||||
* under GFS2_FAST_NAME_SIZE.
|
||||
* This can handle symlinks of any size.
|
||||
*
|
||||
* Returns: 0 on success or error code
|
||||
*/
|
||||
|
|
@ -1079,19 +988,50 @@ static int gfs2_readlink(struct dentry *dentry, char __user *user_buf,
|
|||
static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
|
||||
{
|
||||
struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
|
||||
char array[GFS2_FAST_NAME_SIZE], *buf = array;
|
||||
unsigned int len = GFS2_FAST_NAME_SIZE;
|
||||
struct gfs2_holder i_gh;
|
||||
struct buffer_head *dibh;
|
||||
unsigned int x;
|
||||
char *buf;
|
||||
int error;
|
||||
|
||||
error = gfs2_readlinki(ip, &buf, &len);
|
||||
if (!error) {
|
||||
error = vfs_follow_link(nd, buf);
|
||||
if (buf != array)
|
||||
kfree(buf);
|
||||
} else
|
||||
path_put(&nd->path);
|
||||
gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh);
|
||||
error = gfs2_glock_nq(&i_gh);
|
||||
if (error) {
|
||||
gfs2_holder_uninit(&i_gh);
|
||||
nd_set_link(nd, ERR_PTR(error));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ERR_PTR(error);
|
||||
if (!ip->i_disksize) {
|
||||
gfs2_consist_inode(ip);
|
||||
buf = ERR_PTR(-EIO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
error = gfs2_meta_inode_buffer(ip, &dibh);
|
||||
if (error) {
|
||||
buf = ERR_PTR(error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
x = ip->i_disksize + 1;
|
||||
buf = kmalloc(x, GFP_NOFS);
|
||||
if (!buf)
|
||||
buf = ERR_PTR(-ENOMEM);
|
||||
else
|
||||
memcpy(buf, dibh->b_data + sizeof(struct gfs2_dinode), x);
|
||||
brelse(dibh);
|
||||
out:
|
||||
gfs2_glock_dq_uninit(&i_gh);
|
||||
nd_set_link(nd, buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
|
||||
{
|
||||
char *s = nd_get_link(nd);
|
||||
if (!IS_ERR(s))
|
||||
kfree(s);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1426,8 +1366,9 @@ const struct inode_operations gfs2_dir_iops = {
|
|||
};
|
||||
|
||||
const struct inode_operations gfs2_symlink_iops = {
|
||||
.readlink = gfs2_readlink,
|
||||
.readlink = generic_readlink,
|
||||
.follow_link = gfs2_follow_link,
|
||||
.put_link = gfs2_put_link,
|
||||
.permission = gfs2_permission,
|
||||
.setattr = gfs2_setattr,
|
||||
.getattr = gfs2_getattr,
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ int hpfs_ea_read(struct super_block *s, secno a, int ano, unsigned pos,
|
|||
}
|
||||
|
||||
int hpfs_ea_write(struct super_block *s, secno a, int ano, unsigned pos,
|
||||
unsigned len, char *buf)
|
||||
unsigned len, const char *buf)
|
||||
{
|
||||
struct buffer_head *bh;
|
||||
char *data;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ static int hpfs_hash_dentry(struct dentry *dentry, struct qstr *qstr)
|
|||
|
||||
if (l == 1) if (qstr->name[0]=='.') goto x;
|
||||
if (l == 2) if (qstr->name[0]=='.' || qstr->name[1]=='.') goto x;
|
||||
hpfs_adjust_length((char *)qstr->name, &l);
|
||||
/*if (hpfs_chk_name((char *)qstr->name,&l))*/
|
||||
hpfs_adjust_length(qstr->name, &l);
|
||||
/*if (hpfs_chk_name(qstr->name,&l))*/
|
||||
/*return -ENAMETOOLONG;*/
|
||||
/*return -ENOENT;*/
|
||||
x:
|
||||
|
|
@ -38,14 +38,16 @@ static int hpfs_compare_dentry(struct dentry *dentry, struct qstr *a, struct qst
|
|||
{
|
||||
unsigned al=a->len;
|
||||
unsigned bl=b->len;
|
||||
hpfs_adjust_length((char *)a->name, &al);
|
||||
/*hpfs_adjust_length((char *)b->name, &bl);*/
|
||||
hpfs_adjust_length(a->name, &al);
|
||||
/*hpfs_adjust_length(b->name, &bl);*/
|
||||
/* 'a' is the qstr of an already existing dentry, so the name
|
||||
* must be valid. 'b' must be validated first.
|
||||
*/
|
||||
|
||||
if (hpfs_chk_name((char *)b->name, &bl)) return 1;
|
||||
if (hpfs_compare_names(dentry->d_sb, (char *)a->name, al, (char *)b->name, bl, 0)) return 1;
|
||||
if (hpfs_chk_name(b->name, &bl))
|
||||
return 1;
|
||||
if (hpfs_compare_names(dentry->d_sb, a->name, al, b->name, bl, 0))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue