Commit 48892692 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pull-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull misc filesystem updates from Al Viro:
 "Misc cleanups (the part that hadn't been picked by individual fs
  trees)"

* tag 'pull-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  apparmorfs: don't duplicate kfree_link()
  orangefs: saner arguments passing in readdir guts
  ocfs2_find_match(): there's no such thing as NULL or negative ->d_parent
  reiserfs_add_entry(): get rid of pointless namelen checks
  __ocfs2_add_entry(), ocfs2_prepare_dir_for_insert(): namelen checks
  ext4_add_entry(): ->d_name.len is never 0
  befs: d_obtain_alias(ERR_PTR(...)) will do the right thing
  affs: d_obtain_alias(ERR_PTR(...)) will do the right thing
  /proc/sys: use d_splice_alias() calling conventions to simplify failure exits
  hostfs: use d_splice_alias() calling conventions to simplify failure exits
  udf_fiiter_add_entry(): check for zero ->d_name.len is bogus...
  udf: d_obtain_alias(ERR_PTR(...)) will do the right thing...
  udf: d_splice_alias() will do the right thing on ERR_PTR() inode
  nfsd: kill stale comment about simple_fill_super() requirements
  bfs_add_entry(): get rid of pointless ->d_name.len checks
  nilfs2: d_obtain_alias(ERR_PTR(...)) will do the right thing...
  zonefs: d_splice_alias() will do the right thing on ERR_PTR() inode
parents 499aa1ca c5f3fd21
...@@ -532,9 +532,6 @@ static struct dentry *affs_get_parent(struct dentry *child) ...@@ -532,9 +532,6 @@ static struct dentry *affs_get_parent(struct dentry *child)
parent = affs_iget(child->d_sb, parent = affs_iget(child->d_sb,
be32_to_cpu(AFFS_TAIL(child->d_sb, bh)->parent)); be32_to_cpu(AFFS_TAIL(child->d_sb, bh)->parent));
brelse(bh); brelse(bh);
if (IS_ERR(parent))
return ERR_CAST(parent);
return d_obtain_alias(parent); return d_obtain_alias(parent);
} }
......
...@@ -671,9 +671,6 @@ static struct dentry *befs_get_parent(struct dentry *child) ...@@ -671,9 +671,6 @@ static struct dentry *befs_get_parent(struct dentry *child)
parent = befs_iget(child->d_sb, parent = befs_iget(child->d_sb,
(unsigned long)befs_ino->i_parent.start); (unsigned long)befs_ino->i_parent.start);
if (IS_ERR(parent))
return ERR_CAST(parent);
return d_obtain_alias(parent); return d_obtain_alias(parent);
} }
......
...@@ -275,11 +275,6 @@ static int bfs_add_entry(struct inode *dir, const struct qstr *child, int ino) ...@@ -275,11 +275,6 @@ static int bfs_add_entry(struct inode *dir, const struct qstr *child, int ino)
dprintf("name=%s, namelen=%d\n", name, namelen); dprintf("name=%s, namelen=%d\n", name, namelen);
if (!namelen)
return -ENOENT;
if (namelen > BFS_NAMELEN)
return -ENAMETOOLONG;
sblock = BFS_I(dir)->i_sblock; sblock = BFS_I(dir)->i_sblock;
eblock = BFS_I(dir)->i_eblock; eblock = BFS_I(dir)->i_eblock;
for (block = sblock; block <= eblock; block++) { for (block = sblock; block <= eblock; block++) {
......
...@@ -2388,8 +2388,6 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, ...@@ -2388,8 +2388,6 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
sb = dir->i_sb; sb = dir->i_sb;
blocksize = sb->s_blocksize; blocksize = sb->s_blocksize;
if (!dentry->d_name.len)
return -EINVAL;
if (fscrypt_is_nokey_name(dentry)) if (fscrypt_is_nokey_name(dentry))
return -ENOKEY; return -ENOKEY;
......
...@@ -637,12 +637,8 @@ static struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry, ...@@ -637,12 +637,8 @@ static struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
inode = hostfs_iget(ino->i_sb, name); inode = hostfs_iget(ino->i_sb, name);
__putname(name); __putname(name);
if (IS_ERR(inode)) { if (inode == ERR_PTR(-ENOENT))
if (PTR_ERR(inode) == -ENOENT) inode = NULL;
inode = NULL;
else
return ERR_CAST(inode);
}
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
} }
......
...@@ -48,10 +48,6 @@ enum { ...@@ -48,10 +48,6 @@ enum {
NFSD_MaxBlkSize, NFSD_MaxBlkSize,
NFSD_MaxConnections, NFSD_MaxConnections,
NFSD_Filecache, NFSD_Filecache,
/*
* The below MUST come last. Otherwise we leave a hole in nfsd_files[]
* with !CONFIG_NFSD_V4 and simple_fill_super() goes oops
*/
#ifdef CONFIG_NFSD_V4 #ifdef CONFIG_NFSD_V4
NFSD_Leasetime, NFSD_Leasetime,
NFSD_Gracetime, NFSD_Gracetime,
......
...@@ -441,7 +441,6 @@ static int nilfs_rename(struct mnt_idmap *idmap, ...@@ -441,7 +441,6 @@ static int nilfs_rename(struct mnt_idmap *idmap,
static struct dentry *nilfs_get_parent(struct dentry *child) static struct dentry *nilfs_get_parent(struct dentry *child)
{ {
unsigned long ino; unsigned long ino;
struct inode *inode;
struct nilfs_root *root; struct nilfs_root *root;
ino = nilfs_inode_by_name(d_inode(child), &dotdot_name); ino = nilfs_inode_by_name(d_inode(child), &dotdot_name);
...@@ -450,11 +449,7 @@ static struct dentry *nilfs_get_parent(struct dentry *child) ...@@ -450,11 +449,7 @@ static struct dentry *nilfs_get_parent(struct dentry *child)
root = NILFS_I(d_inode(child))->i_root; root = NILFS_I(d_inode(child))->i_root;
inode = nilfs_iget(child->d_sb, root, ino); return d_obtain_alias(nilfs_iget(child->d_sb, root, ino));
if (IS_ERR(inode))
return ERR_CAST(inode);
return d_obtain_alias(inode);
} }
static struct dentry *nilfs_get_dentry(struct super_block *sb, u64 cno, static struct dentry *nilfs_get_dentry(struct super_block *sb, u64 cno,
......
...@@ -124,17 +124,10 @@ static int ocfs2_match_dentry(struct dentry *dentry, ...@@ -124,17 +124,10 @@ static int ocfs2_match_dentry(struct dentry *dentry,
if (!dentry->d_fsdata) if (!dentry->d_fsdata)
return 0; return 0;
if (!dentry->d_parent)
return 0;
if (skip_unhashed && d_unhashed(dentry)) if (skip_unhashed && d_unhashed(dentry))
return 0; return 0;
parent = d_inode(dentry->d_parent); parent = d_inode(dentry->d_parent);
/* Negative parent dentry? */
if (!parent)
return 0;
/* Name is in a different directory. */ /* Name is in a different directory. */
if (OCFS2_I(parent)->ip_blkno != parent_blkno) if (OCFS2_I(parent)->ip_blkno != parent_blkno)
return 0; return 0;
......
...@@ -1593,9 +1593,6 @@ int __ocfs2_add_entry(handle_t *handle, ...@@ -1593,9 +1593,6 @@ int __ocfs2_add_entry(handle_t *handle,
struct buffer_head *insert_bh = lookup->dl_leaf_bh; struct buffer_head *insert_bh = lookup->dl_leaf_bh;
char *data_start = insert_bh->b_data; char *data_start = insert_bh->b_data;
if (!namelen)
return -EINVAL;
if (ocfs2_dir_indexed(dir)) { if (ocfs2_dir_indexed(dir)) {
struct buffer_head *bh; struct buffer_head *bh;
...@@ -4245,12 +4242,6 @@ int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb, ...@@ -4245,12 +4242,6 @@ int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb,
trace_ocfs2_prepare_dir_for_insert( trace_ocfs2_prepare_dir_for_insert(
(unsigned long long)OCFS2_I(dir)->ip_blkno, namelen); (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen);
if (!namelen) {
ret = -EINVAL;
mlog_errno(ret);
goto out;
}
/* /*
* Do this up front to reduce confusion. * Do this up front to reduce confusion.
* *
......
...@@ -58,10 +58,10 @@ struct orangefs_dir { ...@@ -58,10 +58,10 @@ struct orangefs_dir {
* first part of the part list. * first part of the part list.
*/ */
static int do_readdir(struct orangefs_inode_s *oi, static int do_readdir(struct orangefs_dir *od, struct inode *inode,
struct orangefs_dir *od, struct dentry *dentry,
struct orangefs_kernel_op_s *op) struct orangefs_kernel_op_s *op)
{ {
struct orangefs_inode_s *oi = ORANGEFS_I(inode);
struct orangefs_readdir_response_s *resp; struct orangefs_readdir_response_s *resp;
int bufi, r; int bufi, r;
...@@ -87,7 +87,7 @@ static int do_readdir(struct orangefs_inode_s *oi, ...@@ -87,7 +87,7 @@ static int do_readdir(struct orangefs_inode_s *oi,
op->upcall.req.readdir.buf_index = bufi; op->upcall.req.readdir.buf_index = bufi;
r = service_operation(op, "orangefs_readdir", r = service_operation(op, "orangefs_readdir",
get_interruptible_flag(dentry->d_inode)); get_interruptible_flag(inode));
orangefs_readdir_index_put(bufi); orangefs_readdir_index_put(bufi);
...@@ -158,8 +158,7 @@ static int parse_readdir(struct orangefs_dir *od, ...@@ -158,8 +158,7 @@ static int parse_readdir(struct orangefs_dir *od,
return 0; return 0;
} }
static int orangefs_dir_more(struct orangefs_inode_s *oi, static int orangefs_dir_more(struct orangefs_dir *od, struct inode *inode)
struct orangefs_dir *od, struct dentry *dentry)
{ {
struct orangefs_kernel_op_s *op; struct orangefs_kernel_op_s *op;
int r; int r;
...@@ -169,7 +168,7 @@ static int orangefs_dir_more(struct orangefs_inode_s *oi, ...@@ -169,7 +168,7 @@ static int orangefs_dir_more(struct orangefs_inode_s *oi,
od->error = -ENOMEM; od->error = -ENOMEM;
return -ENOMEM; return -ENOMEM;
} }
r = do_readdir(oi, od, dentry, op); r = do_readdir(od, inode, op);
if (r) { if (r) {
od->error = r; od->error = r;
goto out; goto out;
...@@ -238,9 +237,7 @@ static int fill_from_part(struct orangefs_dir_part *part, ...@@ -238,9 +237,7 @@ static int fill_from_part(struct orangefs_dir_part *part,
return 1; return 1;
} }
static int orangefs_dir_fill(struct orangefs_inode_s *oi, static int orangefs_dir_fill(struct orangefs_dir *od, struct dir_context *ctx)
struct orangefs_dir *od, struct dentry *dentry,
struct dir_context *ctx)
{ {
struct orangefs_dir_part *part; struct orangefs_dir_part *part;
size_t count; size_t count;
...@@ -304,15 +301,10 @@ static loff_t orangefs_dir_llseek(struct file *file, loff_t offset, ...@@ -304,15 +301,10 @@ static loff_t orangefs_dir_llseek(struct file *file, loff_t offset,
static int orangefs_dir_iterate(struct file *file, static int orangefs_dir_iterate(struct file *file,
struct dir_context *ctx) struct dir_context *ctx)
{ {
struct orangefs_inode_s *oi; struct orangefs_dir *od = file->private_data;
struct orangefs_dir *od; struct inode *inode = file_inode(file);
struct dentry *dentry;
int r; int r;
dentry = file->f_path.dentry;
oi = ORANGEFS_I(dentry->d_inode);
od = file->private_data;
if (od->error) if (od->error)
return od->error; return od->error;
...@@ -342,7 +334,7 @@ static int orangefs_dir_iterate(struct file *file, ...@@ -342,7 +334,7 @@ static int orangefs_dir_iterate(struct file *file,
*/ */
while (od->token != ORANGEFS_ITERATE_END && while (od->token != ORANGEFS_ITERATE_END &&
ctx->pos > od->end) { ctx->pos > od->end) {
r = orangefs_dir_more(oi, od, dentry); r = orangefs_dir_more(od, inode);
if (r) if (r)
return r; return r;
} }
...@@ -351,17 +343,17 @@ static int orangefs_dir_iterate(struct file *file, ...@@ -351,17 +343,17 @@ static int orangefs_dir_iterate(struct file *file,
/* Then try to fill if there's any left in the buffer. */ /* Then try to fill if there's any left in the buffer. */
if (ctx->pos < od->end) { if (ctx->pos < od->end) {
r = orangefs_dir_fill(oi, od, dentry, ctx); r = orangefs_dir_fill(od, ctx);
if (r) if (r)
return r; return r;
} }
/* Finally get some more and try to fill. */ /* Finally get some more and try to fill. */
if (od->token != ORANGEFS_ITERATE_END) { if (od->token != ORANGEFS_ITERATE_END) {
r = orangefs_dir_more(oi, od, dentry); r = orangefs_dir_more(od, inode);
if (r) if (r)
return r; return r;
r = orangefs_dir_fill(oi, od, dentry, ctx); r = orangefs_dir_fill(od, ctx);
} }
return r; return r;
......
...@@ -534,13 +534,8 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry, ...@@ -534,13 +534,8 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
goto out; goto out;
} }
inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
if (IS_ERR(inode)) {
err = ERR_CAST(inode);
goto out;
}
d_set_d_op(dentry, &proc_sys_dentry_operations); d_set_d_op(dentry, &proc_sys_dentry_operations);
inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
err = d_splice_alias(inode, dentry); err = d_splice_alias(inode, dentry);
out: out:
...@@ -698,13 +693,8 @@ static bool proc_sys_fill_cache(struct file *file, ...@@ -698,13 +693,8 @@ static bool proc_sys_fill_cache(struct file *file,
return false; return false;
if (d_in_lookup(child)) { if (d_in_lookup(child)) {
struct dentry *res; struct dentry *res;
inode = proc_sys_make_inode(dir->d_sb, head, table);
if (IS_ERR(inode)) {
d_lookup_done(child);
dput(child);
return false;
}
d_set_d_op(child, &proc_sys_dentry_operations); d_set_d_op(child, &proc_sys_dentry_operations);
inode = proc_sys_make_inode(dir->d_sb, head, table);
res = d_splice_alias(inode, child); res = d_splice_alias(inode, child);
d_lookup_done(child); d_lookup_done(child);
if (unlikely(res)) { if (unlikely(res)) {
......
...@@ -451,13 +451,6 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th, ...@@ -451,13 +451,6 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
BUG_ON(!th->t_trans_id); BUG_ON(!th->t_trans_id);
/* cannot allow items to be added into a busy deleted directory */
if (!namelen)
return -EINVAL;
if (namelen > REISERFS_MAX_NAME(dir->i_sb->s_blocksize))
return -ENAMETOOLONG;
/* each entry has unique key. compose it */ /* each entry has unique key. compose it */
make_cpu_key(&entry_key, dir, make_cpu_key(&entry_key, dir,
get_third_component(dir->i_sb, name, namelen), get_third_component(dir->i_sb, name, namelen),
......
...@@ -125,8 +125,6 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, ...@@ -125,8 +125,6 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
udf_fiiter_release(&iter); udf_fiiter_release(&iter);
inode = udf_iget(dir->i_sb, &loc); inode = udf_iget(dir->i_sb, &loc);
if (IS_ERR(inode))
return ERR_CAST(inode);
} }
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
...@@ -230,8 +228,6 @@ static int udf_fiiter_add_entry(struct inode *dir, struct dentry *dentry, ...@@ -230,8 +228,6 @@ static int udf_fiiter_add_entry(struct inode *dir, struct dentry *dentry,
char name[UDF_NAME_LEN_CS0]; char name[UDF_NAME_LEN_CS0];
if (dentry) { if (dentry) {
if (!dentry->d_name.len)
return -EINVAL;
namelen = udf_put_filename(dir->i_sb, dentry->d_name.name, namelen = udf_put_filename(dir->i_sb, dentry->d_name.name,
dentry->d_name.len, dentry->d_name.len,
name, UDF_NAME_LEN_CS0); name, UDF_NAME_LEN_CS0);
...@@ -904,7 +900,6 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir, ...@@ -904,7 +900,6 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
static struct dentry *udf_get_parent(struct dentry *child) static struct dentry *udf_get_parent(struct dentry *child)
{ {
struct kernel_lb_addr tloc; struct kernel_lb_addr tloc;
struct inode *inode = NULL;
struct udf_fileident_iter iter; struct udf_fileident_iter iter;
int err; int err;
...@@ -914,11 +909,7 @@ static struct dentry *udf_get_parent(struct dentry *child) ...@@ -914,11 +909,7 @@ static struct dentry *udf_get_parent(struct dentry *child)
tloc = lelb_to_cpu(iter.fi.icb.extLocation); tloc = lelb_to_cpu(iter.fi.icb.extLocation);
udf_fiiter_release(&iter); udf_fiiter_release(&iter);
inode = udf_iget(child->d_sb, &tloc); return d_obtain_alias(udf_iget(child->d_sb, &tloc));
if (IS_ERR(inode))
return ERR_CAST(inode);
return d_obtain_alias(inode);
} }
......
...@@ -747,8 +747,6 @@ static struct dentry *zonefs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -747,8 +747,6 @@ static struct dentry *zonefs_lookup(struct inode *dir, struct dentry *dentry,
inode = zonefs_get_dir_inode(dir, dentry); inode = zonefs_get_dir_inode(dir, dentry);
else else
inode = zonefs_get_file_inode(dir, dentry); inode = zonefs_get_file_inode(dir, dentry);
if (IS_ERR(inode))
return ERR_CAST(inode);
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
} }
......
...@@ -1615,11 +1615,6 @@ static char *gen_symlink_name(int depth, const char *dirname, const char *fname) ...@@ -1615,11 +1615,6 @@ static char *gen_symlink_name(int depth, const char *dirname, const char *fname)
return buffer; return buffer;
} }
static void rawdata_link_cb(void *arg)
{
kfree(arg);
}
static const char *rawdata_get_link_base(struct dentry *dentry, static const char *rawdata_get_link_base(struct dentry *dentry,
struct inode *inode, struct inode *inode,
struct delayed_call *done, struct delayed_call *done,
...@@ -1643,7 +1638,7 @@ static const char *rawdata_get_link_base(struct dentry *dentry, ...@@ -1643,7 +1638,7 @@ static const char *rawdata_get_link_base(struct dentry *dentry,
if (IS_ERR(target)) if (IS_ERR(target))
return target; return target;
set_delayed_call(done, rawdata_link_cb, target); set_delayed_call(done, kfree_link, target);
return target; return target;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment