Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs

Pull VFS changes from Al Viro:
 "First pile out of several (there _definitely_ will be more).  Stuff in
  this one:

   - unification of d_splice_alias()/d_materialize_unique()

   - iov_iter rewrite

   - killing a bunch of ->f_path.dentry users (and f_dentry macro).

     Getting that completed will make life much simpler for
     unionmount/overlayfs, since then we'll be able to limit the places
     sensitive to file _dentry_ to reasonably few.  Which allows to have
     file_inode(file) pointing to inode in a covered layer, with dentry
     pointing to (negative) dentry in union one.

     Still not complete, but much closer now.

   - crapectomy in lustre (dead code removal, mostly)

   - "let's make seq_printf return nothing" preparations

   - assorted cleanups and fixes

  There _definitely_ will be more piles"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (63 commits)
  copy_from_iter_nocache()
  new helper: iov_iter_kvec()
  csum_and_copy_..._iter()
  iov_iter.c: handle ITER_KVEC directly
  iov_iter.c: convert copy_to_iter() to iterate_and_advance
  iov_iter.c: convert copy_from_iter() to iterate_and_advance
  iov_iter.c: get rid of bvec_copy_page_{to,from}_iter()
  iov_iter.c: convert iov_iter_zero() to iterate_and_advance
  iov_iter.c: convert iov_iter_get_pages_alloc() to iterate_all_kinds
  iov_iter.c: convert iov_iter_get_pages() to iterate_all_kinds
  iov_iter.c: convert iov_iter_npages() to iterate_all_kinds
  iov_iter.c: iterate_and_advance
  iov_iter.c: macros for iterating over iov_iter
  kill f_dentry macro
  dcache: fix kmemcheck warning in switch_names
  new helper: audit_file()
  nfsd_vfs_write(): use file_inode()
  ncpfs: use file_inode()
  kill f_dentry uses
  lockd: get rid of ->f_path.dentry->d_sb
  ...
  • Loading branch information
torvalds committed Dec 11, 2014
2 parents 8322b6f + ba00410 commit cbfe0de
Show file tree
Hide file tree
Showing 157 changed files with 1,666 additions and 2,166 deletions.
2 changes: 1 addition & 1 deletion Documentation/filesystems/debugfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ file.
struct dentry *parent,
struct debugfs_regset32 *regset);

int debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs,
void debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs,
int nregs, void __iomem *base, char *prefix);

The "base" argument may be 0, but you may want to build the reg32 array
Expand Down
23 changes: 5 additions & 18 deletions Documentation/filesystems/nfs/Exporting
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,11 @@ c/ Helper routines to allocate anonymous dentries, and to help attach
DCACHE_DISCONNECTED) dentry is allocated and attached.
In the case of a directory, care is taken that only one dentry
can ever be attached.
d_splice_alias(inode, dentry) or d_materialise_unique(dentry, inode)
will introduce a new dentry into the tree; either the passed-in
dentry or a preexisting alias for the given inode (such as an
anonymous one created by d_obtain_alias), if appropriate. The two
functions differ in their handling of directories with preexisting
aliases:
d_splice_alias will use any existing IS_ROOT dentry, but it will
return -EIO rather than try to move a dentry with a different
parent. This is appropriate for local filesystems, which
should never see such an alias unless the filesystem is
corrupted somehow (for example, if two on-disk directory
entries refer to the same directory.)
d_materialise_unique will attempt to move any dentry. This is
appropriate for distributed filesystems, where finding a
directory other than where we last cached it may be a normal
consequence of concurrent operations on other hosts.
Both functions return NULL when the passed-in dentry is used,
following the calling convention of ->lookup.
d_splice_alias(inode, dentry) will introduce a new dentry into the tree;
either the passed-in dentry or a preexisting alias for the given inode
(such as an anonymous one created by d_obtain_alias), if appropriate.
It returns NULL when the passed-in dentry is used, following the calling
convention of ->lookup.


Filesystem Issues
Expand Down
8 changes: 8 additions & 0 deletions Documentation/filesystems/porting
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,11 @@ in your dentry operations instead.
of the in-tree instances did). inode_hash_lock is still held,
of course, so they are still serialized wrt removal from inode hash,
as well as wrt set() callback of iget5_locked().
--
[mandatory]
d_materialise_unique() is gone; d_splice_alias() does everything you
need now. Remember that they have opposite orders of arguments ;-/
--
[mandatory]
f_dentry is gone; use f_path.dentry, or, better yet, see if you can avoid
it entirely.
22 changes: 13 additions & 9 deletions Documentation/filesystems/seq_file.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,19 @@ output must be passed to the seq_file code. Some utility functions have
been defined which make this task easy.

Most code will simply use seq_printf(), which works pretty much like
printk(), but which requires the seq_file pointer as an argument. It is
common to ignore the return value from seq_printf(), but a function
producing complicated output may want to check that value and quit if
something non-zero is returned; an error return means that the seq_file
buffer has been filled and further output will be discarded.
printk(), but which requires the seq_file pointer as an argument.

For straight character output, the following functions may be used:

int seq_putc(struct seq_file *m, char c);
int seq_puts(struct seq_file *m, const char *s);
int seq_escape(struct seq_file *m, const char *s, const char *esc);
seq_putc(struct seq_file *m, char c);
seq_puts(struct seq_file *m, const char *s);
seq_escape(struct seq_file *m, const char *s, const char *esc);

The first two output a single character and a string, just like one would
expect. seq_escape() is like seq_puts(), except that any character in s
which is in the string esc will be represented in octal form in the output.

There is also a pair of functions for printing filenames:
There are also a pair of functions for printing filenames:

int seq_path(struct seq_file *m, struct path *path, char *esc);
int seq_path_root(struct seq_file *m, struct path *path,
Expand All @@ -209,6 +205,14 @@ root is desired, it can be used with seq_path_root(). Note that, if it
turns out that path cannot be reached from root, the value of root will be
changed in seq_file_root() to a root which *does* work.

A function producing complicated output may want to check
bool seq_has_overflowed(struct seq_file *m);
and avoid further seq_<output> calls if true is returned.

A true return from seq_has_overflowed means that the seq_file buffer will
be discarded and the seq_show function will attempt to allocate a larger
buffer and retry printing.


Making it all work

Expand Down
2 changes: 1 addition & 1 deletion Documentation/filesystems/vfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ struct file_operations {
ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int);
int (*setlease)(struct file *, long arg, struct file_lock **, void **);
long (*fallocate)(struct file *, int mode, loff_t offset, loff_t len);
int (*show_fdinfo)(struct seq_file *m, struct file *f);
void (*show_fdinfo)(struct seq_file *m, struct file *f);
};

Again, all methods are called without any locks being held, unless
Expand Down
7 changes: 4 additions & 3 deletions arch/alpha/kernel/osf_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ struct osf_dirent_callback {
};

static int
osf_filldir(void *__buf, const char *name, int namlen, loff_t offset,
u64 ino, unsigned int d_type)
osf_filldir(struct dir_context *ctx, const char *name, int namlen,
loff_t offset, u64 ino, unsigned int d_type)
{
struct osf_dirent __user *dirent;
struct osf_dirent_callback *buf = (struct osf_dirent_callback *) __buf;
struct osf_dirent_callback *buf =
container_of(ctx, struct osf_dirent_callback, ctx);
unsigned int reclen = ALIGN(NAME_OFFSET + namlen + 1, sizeof(u32));
unsigned int d_ino;

Expand Down
7 changes: 4 additions & 3 deletions arch/parisc/hpux/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ struct getdents_callback {

#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))

static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
u64 ino, unsigned d_type)
static int filldir(struct dir_context *ctx, const char *name, int namlen,
loff_t offset, u64 ino, unsigned d_type)
{
struct hpux_dirent __user * dirent;
struct getdents_callback * buf = (struct getdents_callback *) __buf;
struct getdents_callback *buf =
container_of(ctx, struct getdents_callback, ctx);
ino_t d_ino;
int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, sizeof(long));

Expand Down
10 changes: 4 additions & 6 deletions arch/powerpc/oprofile/cell/spu_task_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,

if (mm->exe_file) {
app_cookie = fast_get_dcookie(&mm->exe_file->f_path);
pr_debug("got dcookie for %s\n",
mm->exe_file->f_dentry->d_name.name);
pr_debug("got dcookie for %pD\n", mm->exe_file);
}

for (vma = mm->mmap; vma; vma = vma->vm_next) {
Expand All @@ -342,15 +341,14 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,
if (!vma->vm_file)
goto fail_no_image_cookie;

pr_debug("Found spu ELF at %X(object-id:%lx) for file %s\n",
my_offset, spu_ref,
vma->vm_file->f_dentry->d_name.name);
pr_debug("Found spu ELF at %X(object-id:%lx) for file %pD\n",
my_offset, spu_ref, vma->vm_file);
*offsetp = my_offset;
break;
}

*spu_bin_dcookie = fast_get_dcookie(&vma->vm_file->f_path);
pr_debug("got dcookie for %s\n", vma->vm_file->f_dentry->d_name.name);
pr_debug("got dcookie for %pD\n", vma->vm_file);

up_read(&mm->mmap_sem);

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static void spufs_prune_dir(struct dentry *dir)
struct dentry *dentry, *tmp;

mutex_lock(&dir->d_inode->i_mutex);
list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_u.d_child) {
list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) {
spin_lock(&dentry->d_lock);
if (!(d_unhashed(dentry)) && dentry->d_inode) {
dget_dlock(dentry);
Expand Down
3 changes: 1 addition & 2 deletions arch/s390/hypfs/hypfs_dbfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ static ssize_t dbfs_read(struct file *file, char __user *buf,

static long dbfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct hypfs_dbfs_file *df;
struct hypfs_dbfs_file *df = file_inode(file)->i_private;
long rc;

df = file->f_path.dentry->d_inode->i_private;
mutex_lock(&df->lock);
if (df->unlocked_ioctl)
rc = df->unlocked_ioctl(file, cmd, arg);
Expand Down
8 changes: 4 additions & 4 deletions arch/x86/ia32/ia32_aout.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ static int load_aout_binary(struct linux_binprm *bprm)
time_after(jiffies, error_time + 5*HZ)) {
printk(KERN_WARNING
"fd_offset is not page aligned. Please convert "
"program: %s\n",
bprm->file->f_path.dentry->d_name.name);
"program: %pD\n",
bprm->file);
error_time = jiffies;
}
#endif
Expand Down Expand Up @@ -429,8 +429,8 @@ static int load_aout_library(struct file *file)
if (time_after(jiffies, error_time + 5*HZ)) {
printk(KERN_WARNING
"N_TXTOFF is not page aligned. Please convert "
"library: %s\n",
file->f_path.dentry->d_name.name);
"library: %pD\n",
file);
error_time = jiffies;
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions drivers/block/drbd/drbd_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ static int in_flight_summary_show(struct seq_file *m, void *pos)
return 0;
}

/* simple_positive(file->f_dentry) respectively debugfs_positive(),
/* simple_positive(file->f_path.dentry) respectively debugfs_positive(),
* but neither is "reachable" from here.
* So we have our own inline version of it above. :-( */
static inline int debugfs_positive(struct dentry *dentry)
Expand All @@ -437,14 +437,14 @@ static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, vo

/* Are we still linked,
* or has debugfs_remove() already been called? */
parent = file->f_dentry->d_parent;
parent = file->f_path.dentry->d_parent;
/* not sure if this can happen: */
if (!parent || !parent->d_inode)
goto out;
/* serialize with d_delete() */
mutex_lock(&parent->d_inode->i_mutex);
/* Make sure the object is still alive */
if (debugfs_positive(file->f_dentry)
if (debugfs_positive(file->f_path.dentry)
&& kref_get_unless_zero(kref))
ret = 0;
mutex_unlock(&parent->d_inode->i_mutex);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/armada/armada_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ struct armada_gem_object *armada_gem_alloc_object(struct drm_device *dev,

obj->dev_addr = DMA_ERROR_CODE;

mapping = obj->obj.filp->f_path.dentry->d_inode->i_mapping;
mapping = file_inode(obj->obj.filp)->i_mapping;
mapping_set_gfp_mask(mapping, GFP_HIGHUSER | __GFP_RECLAIMABLE);

DRM_DEBUG_DRIVER("alloc obj %p size %zu\n", obj, size);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/pci/zoran/zoran_procfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ static ssize_t zoran_write(struct file *file, const char __user *buffer,
return -EFAULT;
}
string[count] = 0;
dprintk(4, KERN_INFO "%s: write_proc: name=%s count=%zu zr=%p\n",
ZR_DEVNAME(zr), file->f_path.dentry->d_name.name, count, zr);
dprintk(4, KERN_INFO "%s: write_proc: name=%pD count=%zu zr=%p\n",
ZR_DEVNAME(zr), file, count, zr);
ldelim = " \t\n";
tdelim = "=";
line = strpbrk(sp, ldelim);
Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/genwqe/card_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static void genwqe_vma_open(struct vm_area_struct *vma)
static void genwqe_vma_close(struct vm_area_struct *vma)
{
unsigned long vsize = vma->vm_end - vma->vm_start;
struct inode *inode = vma->vm_file->f_dentry->d_inode;
struct inode *inode = file_inode(vma->vm_file);
struct dma_mapping *dma_map;
struct genwqe_dev *cd = container_of(inode->i_cdev, struct genwqe_dev,
cdev_genwqe);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,7 @@ static int tun_chr_close(struct inode *inode, struct file *file)
}

#ifdef CONFIG_PROC_FS
static int tun_chr_show_fdinfo(struct seq_file *m, struct file *f)
static void tun_chr_show_fdinfo(struct seq_file *m, struct file *f)
{
struct tun_struct *tun;
struct ifreq ifr;
Expand All @@ -2238,7 +2238,7 @@ static int tun_chr_show_fdinfo(struct seq_file *m, struct file *f)
if (tun)
tun_put(tun);

return seq_printf(m, "iff:\t%s\n", ifr.ifr_name);
seq_printf(m, "iff:\t%s\n", ifr.ifr_name);
}
#endif

Expand Down
16 changes: 7 additions & 9 deletions drivers/s390/char/hmcdrv_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ static int hmcdrv_dev_open(struct inode *inode, struct file *fp)
if (rc)
module_put(THIS_MODULE);

pr_debug("open file '/dev/%s' with return code %d\n",
fp->f_dentry->d_name.name, rc);
pr_debug("open file '/dev/%pD' with return code %d\n", fp, rc);
return rc;
}

Expand All @@ -146,7 +145,7 @@ static int hmcdrv_dev_open(struct inode *inode, struct file *fp)
*/
static int hmcdrv_dev_release(struct inode *inode, struct file *fp)
{
pr_debug("closing file '/dev/%s'\n", fp->f_dentry->d_name.name);
pr_debug("closing file '/dev/%pD'\n", fp);
kfree(fp->private_data);
fp->private_data = NULL;
hmcdrv_ftp_shutdown();
Expand Down Expand Up @@ -231,8 +230,8 @@ static ssize_t hmcdrv_dev_read(struct file *fp, char __user *ubuf,
retlen = hmcdrv_dev_transfer((char *) fp->private_data,
*pos, ubuf, len);

pr_debug("read from file '/dev/%s' at %lld returns %zd/%zu\n",
fp->f_dentry->d_name.name, (long long) *pos, retlen, len);
pr_debug("read from file '/dev/%pD' at %lld returns %zd/%zu\n",
fp, (long long) *pos, retlen, len);

if (retlen > 0)
*pos += retlen;
Expand All @@ -248,8 +247,8 @@ static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
{
ssize_t retlen;

pr_debug("writing file '/dev/%s' at pos. %lld with length %zd\n",
fp->f_dentry->d_name.name, (long long) *pos, len);
pr_debug("writing file '/dev/%pD' at pos. %lld with length %zd\n",
fp, (long long) *pos, len);

if (!fp->private_data) { /* first expect a cmd write */
fp->private_data = kmalloc(len + 1, GFP_KERNEL);
Expand All @@ -272,8 +271,7 @@ static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
if (retlen > 0)
*pos += retlen;

pr_debug("write to file '/dev/%s' returned %zd\n",
fp->f_dentry->d_name.name, retlen);
pr_debug("write to file '/dev/%pD' returned %zd\n", fp, retlen);

return retlen;
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/scsi/lpfc/lpfc_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,8 @@ lpfc_debugfs_dumpDif_open(struct inode *inode, struct file *file)
goto out;

/* Round to page boundary */
printk(KERN_ERR "9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%s\n",
__func__, _dump_buf_dif, file->f_dentry->d_name.name);
printk(KERN_ERR "9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%pD\n",
__func__, _dump_buf_dif, file);
debug->buffer = _dump_buf_dif;
if (!debug->buffer) {
kfree(debug);
Expand Down Expand Up @@ -1011,7 +1011,7 @@ static ssize_t
lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
size_t nbytes, loff_t *ppos)
{
struct dentry *dent = file->f_dentry;
struct dentry *dent = file->f_path.dentry;
struct lpfc_hba *phba = file->private_data;
char cbuf[32];
uint64_t tmp = 0;
Expand Down Expand Up @@ -1052,7 +1052,7 @@ static ssize_t
lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
size_t nbytes, loff_t *ppos)
{
struct dentry *dent = file->f_dentry;
struct dentry *dent = file->f_path.dentry;
struct lpfc_hba *phba = file->private_data;
char dstbuf[32];
uint64_t tmp = 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/staging/lustre/lustre/libcfs/tracefile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,8 @@ static int tracefiled(void *arg)

if (f_pos >= (off_t)cfs_tracefile_size)
f_pos = 0;
else if (f_pos > i_size_read(filp->f_dentry->d_inode))
f_pos = i_size_read(filp->f_dentry->d_inode);
else if (f_pos > i_size_read(file_inode(filp)))
f_pos = i_size_read(file_inode(filp));

buf = kmap(tage->page);
rc = vfs_write(filp, (__force const char __user *)buf,
Expand Down
Loading

0 comments on commit cbfe0de

Please sign in to comment.