Skip to content

Commit 1dc51b8

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more vfs updates from Al Viro: "Assorted VFS fixes and related cleanups (IMO the most interesting in that part are f_path-related things and Eric's descriptor-related stuff). UFS regression fixes (it got broken last cycle). 9P fixes. fs-cache series, DAX patches, Jan's file_remove_suid() work" [ I'd say this is much more than "fixes and related cleanups". The file_table locking rule change by Eric Dumazet is a rather big and fundamental update even if the patch isn't huge. - Linus ] * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (49 commits) 9p: cope with bogus responses from server in p9_client_{read,write} p9_client_write(): avoid double p9_free_req() 9p: forgetting to cancel request on interrupted zero-copy RPC dax: bdev_direct_access() may sleep block: Add support for DAX reads/writes to block devices dax: Use copy_from_iter_nocache dax: Add block size note to documentation fs/file.c: __fget() and dup2() atomicity rules fs/file.c: don't acquire files->file_lock in fd_install() fs:super:get_anon_bdev: fix race condition could cause dev exceed its upper limitation vfs: avoid creation of inode number 0 in get_next_ino namei: make set_root_rcu() return void make simple_positive() public ufs: use dir_pages instead of ufs_dir_pages() pagemap.h: move dir_pages() over there remove the pointless include of lglock.h fs: cleanup slight list_entry abuse xfs: Correctly lock inode when removing suid and file capabilities fs: Call security_ops->inode_killpriv on truncate fs: Provide function telling whether file_remove_privs() will do anything ...
2 parents 9b284cb + 0f1db7d commit 1dc51b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+784
-553
lines changed

Documentation/filesystems/caching/backend-api.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,29 @@ FS-Cache provides some utilities that a cache backend may make use of:
676676
as possible.
677677

678678

679+
(*) Indicate that a stale object was found and discarded:
680+
681+
void fscache_object_retrying_stale(struct fscache_object *object);
682+
683+
This is called to indicate that the lookup procedure found an object in
684+
the cache that the netfs decided was stale. The object has been
685+
discarded from the cache and the lookup will be performed again.
686+
687+
688+
(*) Indicate that the caching backend killed an object:
689+
690+
void fscache_object_mark_killed(struct fscache_object *object,
691+
enum fscache_why_object_killed why);
692+
693+
This is called to indicate that the cache backend preemptively killed an
694+
object. The why parameter should be set to indicate the reason:
695+
696+
FSCACHE_OBJECT_IS_STALE - the object was stale and needs discarding.
697+
FSCACHE_OBJECT_NO_SPACE - there was insufficient cache space
698+
FSCACHE_OBJECT_WAS_RETIRED - the object was retired when relinquished.
699+
FSCACHE_OBJECT_WAS_CULLED - the object was culled to make space.
700+
701+
679702
(*) Get and release references on a retrieval record:
680703

681704
void fscache_get_retrieval(struct fscache_retrieval *op);

Documentation/filesystems/caching/fscache.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ proc files.
284284
enq=N Number of times async ops queued for processing
285285
can=N Number of async ops cancelled
286286
rej=N Number of async ops rejected due to object lookup/create failure
287+
ini=N Number of async ops initialised
287288
dfr=N Number of async ops queued for deferred release
288-
rel=N Number of async ops released
289+
rel=N Number of async ops released (should equal ini=N when idle)
289290
gc=N Number of deferred-release async ops garbage collected
290291
CacheOp alo=N Number of in-progress alloc_object() cache ops
291292
luo=N Number of in-progress lookup_object() cache ops
@@ -303,6 +304,10 @@ proc files.
303304
wrp=N Number of in-progress write_page() cache ops
304305
ucp=N Number of in-progress uncache_page() cache ops
305306
dsp=N Number of in-progress dissociate_pages() cache ops
307+
CacheEv nsp=N Number of object lookups/creations rejected due to lack of space
308+
stl=N Number of stale objects deleted
309+
rtr=N Number of objects retired when relinquished
310+
cul=N Number of objects culled
306311

307312

308313
(*) /proc/fs/fscache/histogram

Documentation/filesystems/dax.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ Usage
1818
-----
1919

2020
If you have a block device which supports DAX, you can make a filesystem
21-
on it as usual. When mounting it, use the -o dax option manually
22-
or add 'dax' to the options in /etc/fstab.
21+
on it as usual. The DAX code currently only supports files with a block
22+
size equal to your kernel's PAGE_SIZE, so you may need to specify a block
23+
size when creating the filesystem. When mounting it, use the "-o dax"
24+
option on the command line or add 'dax' to the options in /etc/fstab.
2325

2426

2527
Implementation Tips for Block Driver Writers

Documentation/filesystems/porting

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,3 +500,7 @@ in your dentry operations instead.
500500
dentry, it does not get nameidata at all and it gets called only when cookie
501501
is non-NULL. Note that link body isn't available anymore, so if you need it,
502502
store it as cookie.
503+
--
504+
[mandatory]
505+
__fd_install() & fd_install() can now sleep. Callers should not
506+
hold a spinlock or other resources that do not allow a schedule.

arch/arc/kernel/troubleshoot.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,12 @@ static void print_task_path_n_nm(struct task_struct *tsk, char *buf)
7171
mmput(mm);
7272

7373
if (exe_file) {
74-
path = exe_file->f_path;
75-
path_get(&exe_file->f_path);
74+
path_nm = file_path(exe_file, buf, 255);
7675
fput(exe_file);
77-
path_nm = d_path(&path, buf, 255);
78-
path_put(&path);
7976
}
8077

8178
done:
82-
pr_info("Path: %s\n", path_nm);
79+
pr_info("Path: %s\n", !IS_ERR(path_nm) ? path_nm : "?");
8380
}
8481

8582
static void show_faulting_vma(unsigned long address, char *buf)
@@ -103,8 +100,7 @@ static void show_faulting_vma(unsigned long address, char *buf)
103100
if (vma && (vma->vm_start <= address)) {
104101
struct file *file = vma->vm_file;
105102
if (file) {
106-
struct path *path = &file->f_path;
107-
nm = d_path(path, buf, PAGE_SIZE - 1);
103+
nm = file_path(file, buf, PAGE_SIZE - 1);
108104
inode = file_inode(vma->vm_file);
109105
dev = inode->i_sb->s_dev;
110106
ino = inode->i_ino;

arch/blackfin/kernel/trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void decode_address(char *buf, unsigned long address)
136136
struct file *file = vma->vm_file;
137137

138138
if (file) {
139-
char *d_name = d_path(&file->f_path, _tmpbuf,
139+
char *d_name = file_path(file, _tmpbuf,
140140
sizeof(_tmpbuf));
141141
if (!IS_ERR(d_name))
142142
name = d_name;

arch/powerpc/platforms/cell/spufs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static void spufs_prune_dir(struct dentry *dir)
166166
mutex_lock(&d_inode(dir)->i_mutex);
167167
list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) {
168168
spin_lock(&dentry->d_lock);
169-
if (!(d_unhashed(dentry)) && d_really_is_positive(dentry)) {
169+
if (simple_positive(dentry)) {
170170
dget_dlock(dentry);
171171
__d_drop(dentry);
172172
spin_unlock(&dentry->d_lock);

arch/s390/hypfs/inode.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,13 @@ static void hypfs_add_dentry(struct dentry *dentry)
6262
hypfs_last_dentry = dentry;
6363
}
6464

65-
static inline int hypfs_positive(struct dentry *dentry)
66-
{
67-
return d_really_is_positive(dentry) && !d_unhashed(dentry);
68-
}
69-
7065
static void hypfs_remove(struct dentry *dentry)
7166
{
7267
struct dentry *parent;
7368

7469
parent = dentry->d_parent;
7570
mutex_lock(&d_inode(parent)->i_mutex);
76-
if (hypfs_positive(dentry)) {
71+
if (simple_positive(dentry)) {
7772
if (d_is_dir(dentry))
7873
simple_rmdir(d_inode(parent), dentry);
7974
else

arch/tile/kernel/stack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static void describe_addr(struct KBacktraceIterator *kbt,
332332
}
333333

334334
if (vma->vm_file) {
335-
p = d_path(&vma->vm_file->f_path, buf, bufsize);
335+
p = file_path(vma->vm_file, buf, bufsize);
336336
if (IS_ERR(p))
337337
p = "?";
338338
name = kbasename(p);

arch/tile/mm/elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static int notify_exec(struct mm_struct *mm)
5656
if (exe_file == NULL)
5757
goto done_free;
5858

59-
path = d_path(&exe_file->f_path, buf, PAGE_SIZE);
59+
path = file_path(exe_file, buf, PAGE_SIZE);
6060
if (IS_ERR(path))
6161
goto done_put;
6262

drivers/block/drbd/drbd_debugfs.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,6 @@ static int in_flight_summary_show(struct seq_file *m, void *pos)
419419
return 0;
420420
}
421421

422-
/* simple_positive(file->f_path.dentry) respectively debugfs_positive(),
423-
* but neither is "reachable" from here.
424-
* So we have our own inline version of it above. :-( */
425-
static inline int debugfs_positive(struct dentry *dentry)
426-
{
427-
return d_really_is_positive(dentry) && !d_unhashed(dentry);
428-
}
429-
430422
/* make sure at *open* time that the respective object won't go away. */
431423
static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, void *),
432424
void *data, struct kref *kref,
@@ -444,7 +436,7 @@ static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, vo
444436
/* serialize with d_delete() */
445437
mutex_lock(&d_inode(parent)->i_mutex);
446438
/* Make sure the object is still alive */
447-
if (debugfs_positive(file->f_path.dentry)
439+
if (simple_positive(file->f_path.dentry)
448440
&& kref_get_unless_zero(kref))
449441
ret = 0;
450442
mutex_unlock(&d_inode(parent)->i_mutex);

drivers/block/loop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf)
588588

589589
spin_lock_irq(&lo->lo_lock);
590590
if (lo->lo_backing_file)
591-
p = d_path(&lo->lo_backing_file->f_path, buf, PAGE_SIZE - 1);
591+
p = file_path(lo->lo_backing_file, buf, PAGE_SIZE - 1);
592592
spin_unlock_irq(&lo->lo_lock);
593593

594594
if (IS_ERR_OR_NULL(p))

drivers/infiniband/hw/ipath/ipath_fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static int remove_file(struct dentry *parent, char *name)
277277
}
278278

279279
spin_lock(&tmp->d_lock);
280-
if (!d_unhashed(tmp) && d_really_is_positive(tmp)) {
280+
if (simple_positive(tmp)) {
281281
dget_dlock(tmp);
282282
__d_drop(tmp);
283283
spin_unlock(&tmp->d_lock);

drivers/infiniband/hw/qib/qib_fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ static int remove_file(struct dentry *parent, char *name)
455455
}
456456

457457
spin_lock(&tmp->d_lock);
458-
if (!d_unhashed(tmp) && d_really_is_positive(tmp)) {
458+
if (simple_positive(tmp)) {
459459
__d_drop(tmp);
460460
spin_unlock(&tmp->d_lock);
461461
simple_unlink(d_inode(parent), tmp);

drivers/md/bitmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ static void bitmap_file_kick(struct bitmap *bitmap)
839839
if (bitmap->storage.file) {
840840
path = kmalloc(PAGE_SIZE, GFP_KERNEL);
841841
if (path)
842-
ptr = d_path(&bitmap->storage.file->f_path,
842+
ptr = file_path(bitmap->storage.file,
843843
path, PAGE_SIZE);
844844

845845
printk(KERN_ALERT
@@ -1927,7 +1927,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
19271927
chunk_kb ? "KB" : "B");
19281928
if (bitmap->storage.file) {
19291929
seq_printf(seq, ", file: ");
1930-
seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
1930+
seq_file_path(seq, bitmap->storage.file, " \t\n");
19311931
}
19321932

19331933
seq_printf(seq, "\n");

drivers/md/md.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5766,7 +5766,7 @@ static int get_bitmap_file(struct mddev *mddev, void __user * arg)
57665766
/* bitmap disabled, zero the first byte and copy out */
57675767
if (!mddev->bitmap_info.file)
57685768
file->pathname[0] = '\0';
5769-
else if ((ptr = d_path(&mddev->bitmap_info.file->f_path,
5769+
else if ((ptr = file_path(mddev->bitmap_info.file,
57705770
file->pathname, sizeof(file->pathname))),
57715771
IS_ERR(ptr))
57725772
err = PTR_ERR(ptr);

drivers/usb/gadget/function/f_mass_storage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2936,7 +2936,7 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg,
29362936
if (fsg_lun_is_open(lun)) {
29372937
p = "(error)";
29382938
if (pathbuf) {
2939-
p = d_path(&lun->filp->f_path, pathbuf, PATH_MAX);
2939+
p = file_path(lun->filp, pathbuf, PATH_MAX);
29402940
if (IS_ERR(p))
29412941
p = "(error)";
29422942
}

drivers/usb/gadget/function/storage_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
341341

342342
down_read(filesem);
343343
if (fsg_lun_is_open(curlun)) { /* Get the complete pathname */
344-
p = d_path(&curlun->filp->f_path, buf, PAGE_SIZE - 1);
344+
p = file_path(curlun->filp, buf, PAGE_SIZE - 1);
345345
if (IS_ERR(p))
346346
rc = PTR_ERR(p);
347347
else {

fs/affs/affs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct affs_inode_info {
6464
/* short cut to get to the affs specific inode data */
6565
static inline struct affs_inode_info *AFFS_I(struct inode *inode)
6666
{
67-
return list_entry(inode, struct affs_inode_info, vfs_inode);
67+
return container_of(inode, struct affs_inode_info, vfs_inode);
6868
}
6969

7070
/*

fs/autofs4/autofs_i.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,6 @@ static inline u64 autofs4_get_ino(struct autofs_sb_info *sbi)
238238
return d_inode(sbi->sb->s_root)->i_ino;
239239
}
240240

241-
static inline int simple_positive(struct dentry *dentry)
242-
{
243-
return d_really_is_positive(dentry) && !d_unhashed(dentry);
244-
}
245-
246241
static inline void __autofs4_add_expiring(struct dentry *dentry)
247242
{
248243
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);

fs/befs/befs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ BEFS_SB(const struct super_block *super)
112112
static inline struct befs_inode_info *
113113
BEFS_I(const struct inode *inode)
114114
{
115-
return list_entry(inode, struct befs_inode_info, vfs_inode);
115+
return container_of(inode, struct befs_inode_info, vfs_inode);
116116
}
117117

118118
static inline befs_blocknr_t

fs/binfmt_elf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ static int fill_files_note(struct memelfnote *note)
15301530
file = vma->vm_file;
15311531
if (!file)
15321532
continue;
1533-
filename = d_path(&file->f_path, name_curpos, remaining);
1533+
filename = file_path(file, name_curpos, remaining);
15341534
if (IS_ERR(filename)) {
15351535
if (PTR_ERR(filename) == -ENAMETOOLONG) {
15361536
vfree(data);
@@ -1540,7 +1540,7 @@ static int fill_files_note(struct memelfnote *note)
15401540
continue;
15411541
}
15421542

1543-
/* d_path() fills at the end, move name down */
1543+
/* file_path() fills at the end, move name down */
15441544
/* n = strlen(filename) + 1: */
15451545
n = (name_curpos + remaining) - filename;
15461546
remaining = filename - name_curpos;

fs/block_dev.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
152152
struct file *file = iocb->ki_filp;
153153
struct inode *inode = file->f_mapping->host;
154154

155+
if (IS_DAX(inode))
156+
return dax_do_io(iocb, inode, iter, offset, blkdev_get_block,
157+
NULL, DIO_SKIP_DIO_COUNT);
155158
return __blockdev_direct_IO(iocb, inode, I_BDEV(inode), iter, offset,
156159
blkdev_get_block, NULL, NULL,
157160
DIO_SKIP_DIO_COUNT);
@@ -443,6 +446,12 @@ long bdev_direct_access(struct block_device *bdev, sector_t sector,
443446
long avail;
444447
const struct block_device_operations *ops = bdev->bd_disk->fops;
445448

449+
/*
450+
* The device driver is allowed to sleep, in order to make the
451+
* memory directly accessible.
452+
*/
453+
might_sleep();
454+
446455
if (size < 0)
447456
return size;
448457
if (!ops->direct_access)
@@ -1170,6 +1179,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
11701179
bdev->bd_disk = disk;
11711180
bdev->bd_queue = disk->queue;
11721181
bdev->bd_contains = bdev;
1182+
bdev->bd_inode->i_flags = disk->fops->direct_access ? S_DAX : 0;
11731183
if (!partno) {
11741184
ret = -ENXIO;
11751185
bdev->bd_part = disk_get_part(disk, partno);

fs/btrfs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
17481748
}
17491749

17501750
current->backing_dev_info = inode_to_bdi(inode);
1751-
err = file_remove_suid(file);
1751+
err = file_remove_privs(file);
17521752
if (err) {
17531753
mutex_unlock(&inode->i_mutex);
17541754
goto out;

fs/cachefiles/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ struct cachefiles_object {
4343
loff_t i_size; /* object size */
4444
unsigned long flags;
4545
#define CACHEFILES_OBJECT_ACTIVE 0 /* T if marked active */
46-
#define CACHEFILES_OBJECT_BURIED 1 /* T if preemptively buried */
4746
atomic_t usage; /* object usage count */
4847
uint8_t type; /* object type */
4948
uint8_t new; /* T if object new */

0 commit comments

Comments
 (0)