Skip to content

Commit e2eff52

Browse files
committed
Merge tag 'v6.4/vfs.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull misc vfs updates from Christian Brauner: "This contains a pile of various smaller fixes. Most of them aren't very interesting so this just highlights things worth mentioning: - Various filesystems contained the same little helper to convert from the mode of a dentry to the DT_* type of that dentry. They have now all been switched to rely on the generic fs_umode_to_dtype() helper. All custom helpers are removed (Jeff) - Fsnotify now reports ACCESS and MODIFY events for splice (Chung-Chiang Cheng) - After converting timerfd a long time ago to rely on wait_event_interruptible_*() apis, convert eventfd as well. This removes the complex open-coded wait code (Wen Yang) - Simplify sysctl registration for devpts, avoiding the declaration of two tables. Instead, just use a prefixed path with register_sysctl() (Luis) - The setattr_should_drop_sgid() helper is now exported so NFS can use it. By switching NFS to this helper an NFS setgid inheritance bug is fixed (me)" * tag 'v6.4/vfs.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: fs: hfsplus: remove WARN_ON() from hfsplus_cat_{read,write}_inode() pnode: pass mountpoint directly eventfd: use wait_event_interruptible_locked_irq() helper splice: report related fsnotify events fs: consolidate duplicate dt_type helpers nfs: use vfs setgid helper Update relatime comments to include equality fs/buffer: Remove redundant assignment to err fs_context: drop the unused lsm_flags member fs/namespace: fnic: Switch to use %ptTd Documentation: update idmappings.rst devpts: simplify two-level sysctl registration for pty_kern_table eventpoll: align comment with nested epoll limitation
2 parents 7bcff5a + 81b21c0 commit e2eff52

21 files changed

Lines changed: 191 additions & 168 deletions

File tree

Documentation/filesystems/idmappings.rst

Lines changed: 125 additions & 53 deletions
Large diffs are not rendered by default.

Documentation/filesystems/mount_api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ context. This is represented by the fs_context structure::
7979
unsigned int sb_flags;
8080
unsigned int sb_flags_mask;
8181
unsigned int s_iflags;
82-
unsigned int lsm_flags;
8382
enum fs_context_purpose purpose:8;
8483
...
8584
};

fs/attr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ int setattr_should_drop_sgid(struct mnt_idmap *idmap,
4747
return ATTR_KILL_SGID;
4848
return 0;
4949
}
50+
EXPORT_SYMBOL(setattr_should_drop_sgid);
5051

5152
/**
5253
* setattr_should_drop_suidgid - determine whether the set{g,u}id bit needs to

fs/buffer.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,7 +2581,7 @@ int block_truncate_page(struct address_space *mapping,
25812581
struct inode *inode = mapping->host;
25822582
struct page *page;
25832583
struct buffer_head *bh;
2584-
int err;
2584+
int err = 0;
25852585

25862586
blocksize = i_blocksize(inode);
25872587
length = offset & (blocksize - 1);
@@ -2594,9 +2594,8 @@ int block_truncate_page(struct address_space *mapping,
25942594
iblock = (sector_t)index << (PAGE_SHIFT - inode->i_blkbits);
25952595

25962596
page = grab_cache_page(mapping, index);
2597-
err = -ENOMEM;
25982597
if (!page)
2599-
goto out;
2598+
return -ENOMEM;
26002599

26012600
if (!page_has_buffers(page))
26022601
create_empty_buffers(page, blocksize, 0);
@@ -2610,7 +2609,6 @@ int block_truncate_page(struct address_space *mapping,
26102609
pos += blocksize;
26112610
}
26122611

2613-
err = 0;
26142612
if (!buffer_mapped(bh)) {
26152613
WARN_ON(bh->b_size != blocksize);
26162614
err = get_block(inode, iblock, bh, 0);
@@ -2634,12 +2632,11 @@ int block_truncate_page(struct address_space *mapping,
26342632

26352633
zero_user(page, offset, length);
26362634
mark_buffer_dirty(bh);
2637-
err = 0;
26382635

26392636
unlock:
26402637
unlock_page(page);
26412638
put_page(page);
2642-
out:
2639+
26432640
return err;
26442641
}
26452642
EXPORT_SYMBOL(block_truncate_page);

fs/configfs/dir.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,12 +1599,6 @@ static int configfs_dir_close(struct inode *inode, struct file *file)
15991599
return 0;
16001600
}
16011601

1602-
/* Relationship between s_mode and the DT_xxx types */
1603-
static inline unsigned char dt_type(struct configfs_dirent *sd)
1604-
{
1605-
return (sd->s_mode >> 12) & 15;
1606-
}
1607-
16081602
static int configfs_readdir(struct file *file, struct dir_context *ctx)
16091603
{
16101604
struct dentry *dentry = file->f_path.dentry;
@@ -1654,7 +1648,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
16541648
name = configfs_get_name(next);
16551649
len = strlen(name);
16561650

1657-
if (!dir_emit(ctx, name, len, ino, dt_type(next)))
1651+
if (!dir_emit(ctx, name, len, ino,
1652+
fs_umode_to_dtype(next->s_mode)))
16581653
return 0;
16591654

16601655
spin_lock(&configfs_dirent_lock);

fs/devpts/inode.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,6 @@ static struct ctl_table pty_table[] = {
7272
{}
7373
};
7474

75-
static struct ctl_table pty_kern_table[] = {
76-
{
77-
.procname = "pty",
78-
.mode = 0555,
79-
.child = pty_table,
80-
},
81-
{}
82-
};
83-
84-
static struct ctl_table pty_root_table[] = {
85-
{
86-
.procname = "kernel",
87-
.mode = 0555,
88-
.child = pty_kern_table,
89-
},
90-
{}
91-
};
92-
9375
struct pts_mount_opts {
9476
int setuid;
9577
int setgid;
@@ -630,7 +612,7 @@ static int __init init_devpts_fs(void)
630612
{
631613
int err = register_filesystem(&devpts_fs_type);
632614
if (!err) {
633-
register_sysctl_table(pty_root_table);
615+
register_sysctl("kernel/pty", pty_table);
634616
}
635617
return err;
636618
}

fs/eventfd.c

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ static ssize_t eventfd_read(struct kiocb *iocb, struct iov_iter *to)
228228
struct file *file = iocb->ki_filp;
229229
struct eventfd_ctx *ctx = file->private_data;
230230
__u64 ucnt = 0;
231-
DECLARE_WAITQUEUE(wait, current);
232231

233232
if (iov_iter_count(to) < sizeof(ucnt))
234233
return -EINVAL;
@@ -239,23 +238,11 @@ static ssize_t eventfd_read(struct kiocb *iocb, struct iov_iter *to)
239238
spin_unlock_irq(&ctx->wqh.lock);
240239
return -EAGAIN;
241240
}
242-
__add_wait_queue(&ctx->wqh, &wait);
243-
for (;;) {
244-
set_current_state(TASK_INTERRUPTIBLE);
245-
if (ctx->count)
246-
break;
247-
if (signal_pending(current)) {
248-
__remove_wait_queue(&ctx->wqh, &wait);
249-
__set_current_state(TASK_RUNNING);
250-
spin_unlock_irq(&ctx->wqh.lock);
251-
return -ERESTARTSYS;
252-
}
241+
242+
if (wait_event_interruptible_locked_irq(ctx->wqh, ctx->count)) {
253243
spin_unlock_irq(&ctx->wqh.lock);
254-
schedule();
255-
spin_lock_irq(&ctx->wqh.lock);
244+
return -ERESTARTSYS;
256245
}
257-
__remove_wait_queue(&ctx->wqh, &wait);
258-
__set_current_state(TASK_RUNNING);
259246
}
260247
eventfd_ctx_do_read(ctx, &ucnt);
261248
current->in_eventfd = 1;
@@ -275,7 +262,6 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
275262
struct eventfd_ctx *ctx = file->private_data;
276263
ssize_t res;
277264
__u64 ucnt;
278-
DECLARE_WAITQUEUE(wait, current);
279265

280266
if (count < sizeof(ucnt))
281267
return -EINVAL;
@@ -288,23 +274,10 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
288274
if (ULLONG_MAX - ctx->count > ucnt)
289275
res = sizeof(ucnt);
290276
else if (!(file->f_flags & O_NONBLOCK)) {
291-
__add_wait_queue(&ctx->wqh, &wait);
292-
for (res = 0;;) {
293-
set_current_state(TASK_INTERRUPTIBLE);
294-
if (ULLONG_MAX - ctx->count > ucnt) {
295-
res = sizeof(ucnt);
296-
break;
297-
}
298-
if (signal_pending(current)) {
299-
res = -ERESTARTSYS;
300-
break;
301-
}
302-
spin_unlock_irq(&ctx->wqh.lock);
303-
schedule();
304-
spin_lock_irq(&ctx->wqh.lock);
305-
}
306-
__remove_wait_queue(&ctx->wqh, &wait);
307-
__set_current_state(TASK_RUNNING);
277+
res = wait_event_interruptible_locked_irq(ctx->wqh,
278+
ULLONG_MAX - ctx->count > ucnt);
279+
if (!res)
280+
res = sizeof(ucnt);
308281
}
309282
if (likely(res > 0)) {
310283
ctx->count += ucnt;

fs/eventpoll.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,8 @@ static inline void ep_set_busy_poll_napi_id(struct epitem *epi)
483483
* (efd1) notices that it may have some event ready, so it needs to wake up
484484
* the waiters on its poll wait list (efd2). So it calls ep_poll_safewake()
485485
* that ends up in another wake_up(), after having checked about the
486-
* recursion constraints. That are, no more than EP_MAX_POLLWAKE_NESTS, to
487-
* avoid stack blasting.
486+
* recursion constraints. That are, no more than EP_MAX_NESTS, to avoid
487+
* stack blasting.
488488
*
489489
* When CONFIG_DEBUG_LOCK_ALLOC is enabled, make sure lockdep can handle
490490
* this special case of epoll.

fs/hfsplus/inode.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,11 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
511511
if (type == HFSPLUS_FOLDER) {
512512
struct hfsplus_cat_folder *folder = &entry.folder;
513513

514-
WARN_ON(fd->entrylength < sizeof(struct hfsplus_cat_folder));
514+
if (fd->entrylength < sizeof(struct hfsplus_cat_folder)) {
515+
pr_err("bad catalog folder entry\n");
516+
res = -EIO;
517+
goto out;
518+
}
515519
hfs_bnode_read(fd->bnode, &entry, fd->entryoffset,
516520
sizeof(struct hfsplus_cat_folder));
517521
hfsplus_get_perms(inode, &folder->permissions, 1);
@@ -531,7 +535,11 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
531535
} else if (type == HFSPLUS_FILE) {
532536
struct hfsplus_cat_file *file = &entry.file;
533537

534-
WARN_ON(fd->entrylength < sizeof(struct hfsplus_cat_file));
538+
if (fd->entrylength < sizeof(struct hfsplus_cat_file)) {
539+
pr_err("bad catalog file entry\n");
540+
res = -EIO;
541+
goto out;
542+
}
535543
hfs_bnode_read(fd->bnode, &entry, fd->entryoffset,
536544
sizeof(struct hfsplus_cat_file));
537545

@@ -562,6 +570,7 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
562570
pr_err("bad catalog entry used to create inode\n");
563571
res = -EIO;
564572
}
573+
out:
565574
return res;
566575
}
567576

@@ -570,6 +579,7 @@ int hfsplus_cat_write_inode(struct inode *inode)
570579
struct inode *main_inode = inode;
571580
struct hfs_find_data fd;
572581
hfsplus_cat_entry entry;
582+
int res = 0;
573583

574584
if (HFSPLUS_IS_RSRC(inode))
575585
main_inode = HFSPLUS_I(inode)->rsrc_inode;
@@ -588,7 +598,11 @@ int hfsplus_cat_write_inode(struct inode *inode)
588598
if (S_ISDIR(main_inode->i_mode)) {
589599
struct hfsplus_cat_folder *folder = &entry.folder;
590600

591-
WARN_ON(fd.entrylength < sizeof(struct hfsplus_cat_folder));
601+
if (fd.entrylength < sizeof(struct hfsplus_cat_folder)) {
602+
pr_err("bad catalog folder entry\n");
603+
res = -EIO;
604+
goto out;
605+
}
592606
hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
593607
sizeof(struct hfsplus_cat_folder));
594608
/* simple node checks? */
@@ -613,7 +627,11 @@ int hfsplus_cat_write_inode(struct inode *inode)
613627
} else {
614628
struct hfsplus_cat_file *file = &entry.file;
615629

616-
WARN_ON(fd.entrylength < sizeof(struct hfsplus_cat_file));
630+
if (fd.entrylength < sizeof(struct hfsplus_cat_file)) {
631+
pr_err("bad catalog file entry\n");
632+
res = -EIO;
633+
goto out;
634+
}
617635
hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
618636
sizeof(struct hfsplus_cat_file));
619637
hfsplus_inode_write_fork(inode, &file->data_fork);
@@ -634,7 +652,7 @@ int hfsplus_cat_write_inode(struct inode *inode)
634652
set_bit(HFSPLUS_I_CAT_DIRTY, &HFSPLUS_I(inode)->flags);
635653
out:
636654
hfs_find_exit(&fd);
637-
return 0;
655+
return res;
638656
}
639657

640658
int hfsplus_fileattr_get(struct dentry *dentry, struct fileattr *fa)

fs/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,8 +1804,8 @@ EXPORT_SYMBOL(bmap);
18041804

18051805
/*
18061806
* With relative atime, only update atime if the previous atime is
1807-
* earlier than either the ctime or mtime or if at least a day has
1808-
* passed since the last atime update.
1807+
* earlier than or equal to either the ctime or mtime,
1808+
* or if at least a day has passed since the last atime update.
18091809
*/
18101810
static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
18111811
struct timespec64 now)
@@ -1814,12 +1814,12 @@ static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
18141814
if (!(mnt->mnt_flags & MNT_RELATIME))
18151815
return 1;
18161816
/*
1817-
* Is mtime younger than atime? If yes, update atime:
1817+
* Is mtime younger than or equal to atime? If yes, update atime:
18181818
*/
18191819
if (timespec64_compare(&inode->i_mtime, &inode->i_atime) >= 0)
18201820
return 1;
18211821
/*
1822-
* Is ctime younger than atime? If yes, update atime:
1822+
* Is ctime younger than or equal to atime? If yes, update atime:
18231823
*/
18241824
if (timespec64_compare(&inode->i_ctime, &inode->i_atime) >= 0)
18251825
return 1;

0 commit comments

Comments
 (0)