Skip to content

Commit be5e661

Browse files
committed
Merge branch 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more vfs updates from Al Viro: "Assorted stuff from this cycle. The big ones here are multilayer overlayfs from Miklos and beginning of sorting ->d_inode accesses out from David" * 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (51 commits) autofs4 copy_dev_ioctl(): keep the value of ->size we'd used for allocation procfs: fix race between symlink removals and traversals debugfs: leave freeing a symlink body until inode eviction Documentation/filesystems/Locking: ->get_sb() is long gone trylock_super(): replacement for grab_super_passive() fanotify: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions Cachefiles: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry) SELinux: Use d_is_positive() rather than testing dentry->d_inode Smack: Use d_is_positive() rather than testing dentry->d_inode TOMOYO: Use d_is_dir() rather than d_inode and S_ISDIR() Apparmor: Use d_is_positive/negative() rather than testing dentry->d_inode Apparmor: mediated_filesystem() should use dentry->d_sb not inode->i_sb VFS: Split DCACHE_FILE_TYPE into regular and special types VFS: Add a fallthrough flag for marking virtual dentries VFS: Add a whiteout dentry type VFS: Introduce inode-getting helpers for layered/unioned fs environments Infiniband: Fix potential NULL d_inode dereference posix_acl: fix reference leaks in posix_acl_create autofs4: Wrong format for printing dentry ...
2 parents 90c453c + 0a28096 commit be5e661

File tree

70 files changed

+907
-758
lines changed

Some content is hidden

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

70 files changed

+907
-758
lines changed

Documentation/filesystems/Locking

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ the block device inode. See there for more details.
164164

165165
--------------------------- file_system_type ---------------------------
166166
prototypes:
167-
int (*get_sb) (struct file_system_type *, int,
168-
const char *, void *, struct vfsmount *);
169167
struct dentry *(*mount) (struct file_system_type *, int,
170168
const char *, void *);
171169
void (*kill_sb) (struct super_block *);

Documentation/filesystems/overlayfs.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,22 @@ overlay filesystem (though an operation on the name of the file such as
159159
rename or unlink will of course be noticed and handled).
160160

161161

162+
Multiple lower layers
163+
---------------------
164+
165+
Multiple lower layers can now be given using the the colon (":") as a
166+
separator character between the directory names. For example:
167+
168+
mount -t overlay overlay -olowerdir=/lower1:/lower2:/lower3 /merged
169+
170+
As the example shows, "upperdir=" and "workdir=" may be omitted. In
171+
that case the overlay will be read-only.
172+
173+
The specified lower directories will be stacked beginning from the
174+
rightmost one and going left. In the above example lower1 will be the
175+
top, lower2 the middle and lower3 the bottom layer.
176+
177+
162178
Non-standard behavior
163179
---------------------
164180

@@ -196,3 +212,15 @@ Changes to the underlying filesystems while part of a mounted overlay
196212
filesystem are not allowed. If the underlying filesystem is changed,
197213
the behavior of the overlay is undefined, though it will not result in
198214
a crash or deadlock.
215+
216+
Testsuite
217+
---------
218+
219+
There's testsuite developed by David Howells at:
220+
221+
git://git.infradead.org/users/dhowells/unionmount-testsuite.git
222+
223+
Run as root:
224+
225+
# cd unionmount-testsuite
226+
# ./run --ov

arch/s390/hypfs/inode.c

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void hypfs_remove(struct dentry *dentry)
7474
parent = dentry->d_parent;
7575
mutex_lock(&parent->d_inode->i_mutex);
7676
if (hypfs_positive(dentry)) {
77-
if (S_ISDIR(dentry->d_inode->i_mode))
77+
if (d_is_dir(dentry))
7878
simple_rmdir(parent->d_inode, dentry);
7979
else
8080
simple_unlink(parent->d_inode, dentry);
@@ -144,36 +144,32 @@ static int hypfs_open(struct inode *inode, struct file *filp)
144144
return nonseekable_open(inode, filp);
145145
}
146146

147-
static ssize_t hypfs_aio_read(struct kiocb *iocb, const struct iovec *iov,
148-
unsigned long nr_segs, loff_t offset)
147+
static ssize_t hypfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
149148
{
150-
char *data;
151-
ssize_t ret;
152-
struct file *filp = iocb->ki_filp;
153-
/* XXX: temporary */
154-
char __user *buf = iov[0].iov_base;
155-
size_t count = iov[0].iov_len;
156-
157-
if (nr_segs != 1)
158-
return -EINVAL;
159-
160-
data = filp->private_data;
161-
ret = simple_read_from_buffer(buf, count, &offset, data, strlen(data));
162-
if (ret <= 0)
163-
return ret;
149+
struct file *file = iocb->ki_filp;
150+
char *data = file->private_data;
151+
size_t available = strlen(data);
152+
loff_t pos = iocb->ki_pos;
153+
size_t count;
164154

165-
iocb->ki_pos += ret;
166-
file_accessed(filp);
167-
168-
return ret;
155+
if (pos < 0)
156+
return -EINVAL;
157+
if (pos >= available || !iov_iter_count(to))
158+
return 0;
159+
count = copy_to_iter(data + pos, available - pos, to);
160+
if (!count)
161+
return -EFAULT;
162+
iocb->ki_pos = pos + count;
163+
file_accessed(file);
164+
return count;
169165
}
170-
static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov,
171-
unsigned long nr_segs, loff_t offset)
166+
167+
static ssize_t hypfs_write_iter(struct kiocb *iocb, struct iov_iter *from)
172168
{
173169
int rc;
174170
struct super_block *sb = file_inode(iocb->ki_filp)->i_sb;
175171
struct hypfs_sb_info *fs_info = sb->s_fs_info;
176-
size_t count = iov_length(iov, nr_segs);
172+
size_t count = iov_iter_count(from);
177173

178174
/*
179175
* Currently we only allow one update per second for two reasons:
@@ -202,6 +198,7 @@ static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov,
202198
}
203199
hypfs_update_update(sb);
204200
rc = count;
201+
iov_iter_advance(from, count);
205202
out:
206203
mutex_unlock(&fs_info->lock);
207204
return rc;
@@ -440,10 +437,10 @@ struct dentry *hypfs_create_str(struct dentry *dir,
440437
static const struct file_operations hypfs_file_ops = {
441438
.open = hypfs_open,
442439
.release = hypfs_release,
443-
.read = do_sync_read,
444-
.write = do_sync_write,
445-
.aio_read = hypfs_aio_read,
446-
.aio_write = hypfs_aio_write,
440+
.read = new_sync_read,
441+
.write = new_sync_write,
442+
.read_iter = hypfs_read_iter,
443+
.write_iter = hypfs_write_iter,
447444
.llseek = no_llseek,
448445
};
449446

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) && tmp->d_inode)) {
280+
if (!d_unhashed(tmp) && tmp->d_inode) {
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) && tmp->d_inode)) {
458+
if (!d_unhashed(tmp) && tmp->d_inode) {
459459
__d_drop(tmp);
460460
spin_unlock(&tmp->d_lock);
461461
simple_unlink(parent->d_inode, tmp);

drivers/staging/lustre/lustre/llite/dcache.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ void ll_invalidate_aliases(struct inode *inode)
270270

271271
int ll_revalidate_it_finish(struct ptlrpc_request *request,
272272
struct lookup_intent *it,
273-
struct dentry *de)
273+
struct inode *inode)
274274
{
275275
int rc = 0;
276276

@@ -280,19 +280,17 @@ int ll_revalidate_it_finish(struct ptlrpc_request *request,
280280
if (it_disposition(it, DISP_LOOKUP_NEG))
281281
return -ENOENT;
282282

283-
rc = ll_prep_inode(&de->d_inode, request, NULL, it);
283+
rc = ll_prep_inode(&inode, request, NULL, it);
284284

285285
return rc;
286286
}
287287

288-
void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry)
288+
void ll_lookup_finish_locks(struct lookup_intent *it, struct inode *inode)
289289
{
290290
LASSERT(it != NULL);
291-
LASSERT(dentry != NULL);
292291

293-
if (it->d.lustre.it_lock_mode && dentry->d_inode != NULL) {
294-
struct inode *inode = dentry->d_inode;
295-
struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode);
292+
if (it->d.lustre.it_lock_mode && inode != NULL) {
293+
struct ll_sb_info *sbi = ll_i2sbi(inode);
296294

297295
CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
298296
inode, inode->i_ino, inode->i_generation);

drivers/staging/lustre/lustre/llite/file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,8 +2912,8 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
29122912
oit.it_op = IT_LOOKUP;
29132913

29142914
/* Call getattr by fid, so do not provide name at all. */
2915-
op_data = ll_prep_md_op_data(NULL, dentry->d_inode,
2916-
dentry->d_inode, NULL, 0, 0,
2915+
op_data = ll_prep_md_op_data(NULL, inode,
2916+
inode, NULL, 0, 0,
29172917
LUSTRE_OPC_ANY, NULL);
29182918
if (IS_ERR(op_data))
29192919
return PTR_ERR(op_data);
@@ -2931,7 +2931,7 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
29312931
goto out;
29322932
}
29332933

2934-
rc = ll_revalidate_it_finish(req, &oit, dentry);
2934+
rc = ll_revalidate_it_finish(req, &oit, inode);
29352935
if (rc != 0) {
29362936
ll_intent_release(&oit);
29372937
goto out;
@@ -2944,7 +2944,7 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
29442944
if (!dentry->d_inode->i_nlink)
29452945
d_lustre_invalidate(dentry, 0);
29462946

2947-
ll_lookup_finish_locks(&oit, dentry);
2947+
ll_lookup_finish_locks(&oit, inode);
29482948
} else if (!ll_have_md_lock(dentry->d_inode, &ibits, LCK_MINMODE)) {
29492949
struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode);
29502950
u64 valid = OBD_MD_FLGETATTR;

drivers/staging/lustre/lustre/llite/llite_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,9 @@ extern const struct dentry_operations ll_d_ops;
786786
void ll_intent_drop_lock(struct lookup_intent *);
787787
void ll_intent_release(struct lookup_intent *);
788788
void ll_invalidate_aliases(struct inode *);
789-
void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
789+
void ll_lookup_finish_locks(struct lookup_intent *it, struct inode *inode);
790790
int ll_revalidate_it_finish(struct ptlrpc_request *request,
791-
struct lookup_intent *it, struct dentry *de);
791+
struct lookup_intent *it, struct inode *inode);
792792

793793
/* llite/llite_lib.c */
794794
extern struct super_operations lustre_super_operations;

drivers/staging/lustre/lustre/llite/namei.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
481481
struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
482482
struct dentry *save = dentry, *retval;
483483
struct ptlrpc_request *req = NULL;
484+
struct inode *inode;
484485
struct md_op_data *op_data;
485486
__u32 opc;
486487
int rc;
@@ -539,12 +540,13 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
539540
goto out;
540541
}
541542

542-
if ((it->it_op & IT_OPEN) && dentry->d_inode &&
543-
!S_ISREG(dentry->d_inode->i_mode) &&
544-
!S_ISDIR(dentry->d_inode->i_mode)) {
545-
ll_release_openhandle(dentry->d_inode, it);
543+
inode = dentry->d_inode;
544+
if ((it->it_op & IT_OPEN) && inode &&
545+
!S_ISREG(inode->i_mode) &&
546+
!S_ISDIR(inode->i_mode)) {
547+
ll_release_openhandle(inode, it);
546548
}
547-
ll_lookup_finish_locks(it, dentry);
549+
ll_lookup_finish_locks(it, inode);
548550

549551
if (dentry == save)
550552
retval = NULL;

fs/9p/vfs_inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
11271127
}
11281128

11291129
/* Write all dirty data */
1130-
if (S_ISREG(dentry->d_inode->i_mode))
1130+
if (d_is_reg(dentry))
11311131
filemap_write_and_wait(dentry->d_inode->i_mapping);
11321132

11331133
retval = p9_client_wstat(fid, &wstat);

fs/aio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ SYSCALL_DEFINE2(io_setup, unsigned, nr_events, aio_context_t __user *, ctxp)
12851285

12861286
ret = -EINVAL;
12871287
if (unlikely(ctx || nr_events == 0)) {
1288-
pr_debug("EINVAL: io_setup: ctx %lu nr_events %u\n",
1288+
pr_debug("EINVAL: ctx %lu nr_events %u\n",
12891289
ctx, nr_events);
12901290
goto out;
12911291
}
@@ -1333,7 +1333,7 @@ SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx)
13331333

13341334
return ret;
13351335
}
1336-
pr_debug("EINVAL: io_destroy: invalid context id\n");
1336+
pr_debug("EINVAL: invalid context id\n");
13371337
return -EINVAL;
13381338
}
13391339

@@ -1515,7 +1515,7 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
15151515
(iocb->aio_nbytes != (size_t)iocb->aio_nbytes) ||
15161516
((ssize_t)iocb->aio_nbytes < 0)
15171517
)) {
1518-
pr_debug("EINVAL: io_submit: overflow check\n");
1518+
pr_debug("EINVAL: overflow check\n");
15191519
return -EINVAL;
15201520
}
15211521

fs/autofs4/dev-ioctl.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int check_dev_ioctl_version(int cmd, struct autofs_dev_ioctl *param)
9595
*/
9696
static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *in)
9797
{
98-
struct autofs_dev_ioctl tmp;
98+
struct autofs_dev_ioctl tmp, *res;
9999

100100
if (copy_from_user(&tmp, in, sizeof(tmp)))
101101
return ERR_PTR(-EFAULT);
@@ -106,7 +106,11 @@ static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *i
106106
if (tmp.size > (PATH_MAX + sizeof(tmp)))
107107
return ERR_PTR(-ENAMETOOLONG);
108108

109-
return memdup_user(in, tmp.size);
109+
res = memdup_user(in, tmp.size);
110+
if (!IS_ERR(res))
111+
res->size = tmp.size;
112+
113+
return res;
110114
}
111115

112116
static inline void free_dev_ioctl(struct autofs_dev_ioctl *param)

fs/autofs4/expire.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static struct dentry *should_expire(struct dentry *dentry,
374374
return NULL;
375375
}
376376

377-
if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) {
377+
if (dentry->d_inode && d_is_symlink(dentry)) {
378378
DPRINTK("checking symlink %p %pd", dentry, dentry);
379379
/*
380380
* A symlink can't be "busy" in the usual sense so

fs/autofs4/root.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
108108
struct dentry *dentry = file->f_path.dentry;
109109
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
110110

111-
DPRINTK("file=%p dentry=%p %pD", file, dentry, dentry);
111+
DPRINTK("file=%p dentry=%p %pd", file, dentry, dentry);
112112

113113
if (autofs4_oz_mode(sbi))
114114
goto out;
@@ -371,7 +371,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
371371
* having d_mountpoint() true, so there's no need to call back
372372
* to the daemon.
373373
*/
374-
if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) {
374+
if (dentry->d_inode && d_is_symlink(dentry)) {
375375
spin_unlock(&sbi->fs_lock);
376376
goto done;
377377
}
@@ -485,7 +485,7 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk)
485485
* an incorrect ELOOP error return.
486486
*/
487487
if ((!d_mountpoint(dentry) && !simple_empty(dentry)) ||
488-
(dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)))
488+
(dentry->d_inode && d_is_symlink(dentry)))
489489
status = -EISDIR;
490490
}
491491
spin_unlock(&sbi->fs_lock);

0 commit comments

Comments
 (0)