Skip to content

Commit 1b0aabc

Browse files
committed
Merge tag 'vfs-6.10.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull misc vfs updates from Christian Brauner: "This contains the usual miscellaneous features, cleanups, and fixes for vfs and individual fses. Features: - Free up FMODE_* bits. I've freed up bits 6, 7, 8, and 24. That means we now have six free FMODE_* bits in total (but bit #6 already got used for FMODE_WRITE_RESTRICTED) - Add FOP_HUGE_PAGES flag (follow-up to FMODE_* cleanup) - Add fd_raw cleanup class so we can make use of automatic cleanup provided by CLASS(fd_raw, f)(fd) for O_PATH fds as well - Optimize seq_puts() - Simplify __seq_puts() - Add new anon_inode_getfile_fmode() api to allow specifying f_mode instead of open-coding it in multiple places - Annotate struct file_handle with __counted_by() and use struct_size() - Warn in get_file() whether f_count resurrection from zero is attempted (epoll/drm discussion) - Folio-sophize aio - Export the subvolume id in statx() for both btrfs and bcachefs - Relax linkat(AT_EMPTY_PATH) requirements - Add F_DUPFD_QUERY fcntl() allowing to compare two file descriptors for dup*() equality replacing kcmp() Cleanups: - Compile out swapfile inode checks when swap isn't enabled - Use (1 << n) notation for FMODE_* bitshifts for clarity - Remove redundant variable assignment in fs/direct-io - Cleanup uses of strncpy in orangefs - Speed up and cleanup writeback - Move fsparam_string_empty() helper into header since it's currently open-coded in multiple places - Add kernel-doc comments to proc_create_net_data_write() - Don't needlessly read dentry->d_flags twice Fixes: - Fix out-of-range warning in nilfs2 - Fix ecryptfs overflow due to wrong encryption packet size calculation - Fix overly long line in xfs file_operations (follow-up to FMODE_* cleanup) - Don't raise FOP_BUFFER_{R,W}ASYNC for directories in xfs (follow-up to FMODE_* cleanup) - Don't call xfs_file_open from xfs_dir_open (follow-up to FMODE_* cleanup) - Fix stable offset api to prevent endless loops - Fix afs file server rotations - Prevent xattr node from overflowing the eraseblock in jffs2 - Move fdinfo PTRACE_MODE_READ procfs check into the .permission() operation instead of .open() operation since this caused userspace regressions" * tag 'vfs-6.10.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (39 commits) afs: Fix fileserver rotation getting stuck selftests: add F_DUPDFD_QUERY selftests fcntl: add F_DUPFD_QUERY fcntl() file: add fd_raw cleanup class fs: WARN when f_count resurrection is attempted seq_file: Simplify __seq_puts() seq_file: Optimize seq_puts() proc: Move fdinfo PTRACE_MODE_READ check into the inode .permission operation fs: Create anon_inode_getfile_fmode() xfs: don't call xfs_file_open from xfs_dir_open xfs: drop fop_flags for directories xfs: fix overly long line in the file_operations shmem: Fix shmem_rename2() libfs: Add simple_offset_rename() API libfs: Fix simple_offset_rename_exchange() jffs2: prevent xattr node from overflowing the eraseblock vfs, swap: compile out IS_SWAPFILE() on swapless configs vfs: relax linkat() AT_EMPTY_PATH - aka flink() - requirements fs/direct-io: remove redundant assignment to variable retval fs/dcache: Re-use value stored to dentry->d_flags instead of re-reading ...
2 parents c117a43 + da0e01c commit 1b0aabc

Some content is hidden

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

50 files changed

+438
-249
lines changed

block/bdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder,
912912
disk_unblock_events(disk);
913913

914914
bdev_file->f_flags |= O_LARGEFILE;
915-
bdev_file->f_mode |= FMODE_BUF_RASYNC | FMODE_CAN_ODIRECT;
915+
bdev_file->f_mode |= FMODE_CAN_ODIRECT;
916916
if (bdev_nowait(bdev))
917917
bdev_file->f_mode |= FMODE_NOWAIT;
918918
if (mode & BLK_OPEN_RESTRICT_WRITES)

block/fops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ const struct file_operations def_blk_fops = {
863863
.splice_read = filemap_splice_read,
864864
.splice_write = iter_file_splice_write,
865865
.fallocate = blkdev_fallocate,
866+
.fop_flags = FOP_BUFFER_RASYNC,
866867
};
867868

868869
static __init int blkdev_init(void)

drivers/dax/device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ static const struct file_operations dax_fops = {
377377
.release = dax_release,
378378
.get_unmapped_area = dax_get_unmapped_area,
379379
.mmap = dax_mmap,
380-
.mmap_supported_flags = MAP_SYNC,
380+
.fop_flags = FOP_MMAP_SYNC,
381381
};
382382

383383
static void dev_dax_cdev_del(void *cdev)

fs/afs/rotate.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,11 +541,13 @@ bool afs_select_fileserver(struct afs_operation *op)
541541
test_bit(AFS_SE_EXCLUDED, &se->flags) ||
542542
!test_bit(AFS_SERVER_FL_RESPONDING, &s->flags))
543543
continue;
544-
es = op->server_states->endpoint_state;
544+
es = op->server_states[i].endpoint_state;
545545
sal = es->addresses;
546546

547547
afs_get_address_preferences_rcu(op->net, sal);
548548
for (j = 0; j < sal->nr_addrs; j++) {
549+
if (es->failed_set & (1 << j))
550+
continue;
549551
if (!sal->addrs[j].peer)
550552
continue;
551553
if (sal->addrs[j].prio > best_prio) {
@@ -605,6 +607,8 @@ bool afs_select_fileserver(struct afs_operation *op)
605607
best_prio = -1;
606608
addr_index = 0;
607609
for (i = 0; i < alist->nr_addrs; i++) {
610+
if (!(set & (1 << i)))
611+
continue;
608612
if (alist->addrs[i].prio > best_prio) {
609613
addr_index = i;
610614
best_prio = alist->addrs[i].prio;
@@ -674,7 +678,7 @@ bool afs_select_fileserver(struct afs_operation *op)
674678
for (i = 0; i < op->server_list->nr_servers; i++) {
675679
struct afs_endpoint_state *estate;
676680

677-
estate = op->server_states->endpoint_state;
681+
estate = op->server_states[i].endpoint_state;
678682
error = READ_ONCE(estate->error);
679683
if (error < 0)
680684
afs_op_accumulate_error(op, error, estate->abort_code);

fs/aio.c

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ struct kioctx {
122122
unsigned long mmap_base;
123123
unsigned long mmap_size;
124124

125-
struct page **ring_pages;
125+
struct folio **ring_folios;
126126
long nr_pages;
127127

128128
struct rcu_work free_rwork; /* see free_ioctx() */
@@ -160,7 +160,7 @@ struct kioctx {
160160
spinlock_t completion_lock;
161161
} ____cacheline_aligned_in_smp;
162162

163-
struct page *internal_pages[AIO_RING_PAGES];
163+
struct folio *internal_folios[AIO_RING_PAGES];
164164
struct file *aio_ring_file;
165165

166166
unsigned id;
@@ -334,19 +334,20 @@ static void aio_free_ring(struct kioctx *ctx)
334334
put_aio_ring_file(ctx);
335335

336336
for (i = 0; i < ctx->nr_pages; i++) {
337-
struct page *page;
338-
pr_debug("pid(%d) [%d] page->count=%d\n", current->pid, i,
339-
page_count(ctx->ring_pages[i]));
340-
page = ctx->ring_pages[i];
341-
if (!page)
337+
struct folio *folio = ctx->ring_folios[i];
338+
339+
if (!folio)
342340
continue;
343-
ctx->ring_pages[i] = NULL;
344-
put_page(page);
341+
342+
pr_debug("pid(%d) [%d] folio->count=%d\n", current->pid, i,
343+
folio_ref_count(folio));
344+
ctx->ring_folios[i] = NULL;
345+
folio_put(folio);
345346
}
346347

347-
if (ctx->ring_pages && ctx->ring_pages != ctx->internal_pages) {
348-
kfree(ctx->ring_pages);
349-
ctx->ring_pages = NULL;
348+
if (ctx->ring_folios && ctx->ring_folios != ctx->internal_folios) {
349+
kfree(ctx->ring_folios);
350+
ctx->ring_folios = NULL;
350351
}
351352
}
352353

@@ -441,7 +442,7 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst,
441442
idx = src->index;
442443
if (idx < (pgoff_t)ctx->nr_pages) {
443444
/* Make sure the old folio hasn't already been changed */
444-
if (ctx->ring_pages[idx] != &src->page)
445+
if (ctx->ring_folios[idx] != src)
445446
rc = -EAGAIN;
446447
} else
447448
rc = -EINVAL;
@@ -465,8 +466,8 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst,
465466
*/
466467
spin_lock_irqsave(&ctx->completion_lock, flags);
467468
folio_migrate_copy(dst, src);
468-
BUG_ON(ctx->ring_pages[idx] != &src->page);
469-
ctx->ring_pages[idx] = &dst->page;
469+
BUG_ON(ctx->ring_folios[idx] != src);
470+
ctx->ring_folios[idx] = dst;
470471
spin_unlock_irqrestore(&ctx->completion_lock, flags);
471472

472473
/* The old folio is no longer accessible. */
@@ -516,28 +517,30 @@ static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events)
516517
nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring))
517518
/ sizeof(struct io_event);
518519

519-
ctx->ring_pages = ctx->internal_pages;
520+
ctx->ring_folios = ctx->internal_folios;
520521
if (nr_pages > AIO_RING_PAGES) {
521-
ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *),
522-
GFP_KERNEL);
523-
if (!ctx->ring_pages) {
522+
ctx->ring_folios = kcalloc(nr_pages, sizeof(struct folio *),
523+
GFP_KERNEL);
524+
if (!ctx->ring_folios) {
524525
put_aio_ring_file(ctx);
525526
return -ENOMEM;
526527
}
527528
}
528529

529530
for (i = 0; i < nr_pages; i++) {
530-
struct page *page;
531-
page = find_or_create_page(file->f_mapping,
532-
i, GFP_USER | __GFP_ZERO);
533-
if (!page)
531+
struct folio *folio;
532+
533+
folio = __filemap_get_folio(file->f_mapping, i,
534+
FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
535+
GFP_USER | __GFP_ZERO);
536+
if (IS_ERR(folio))
534537
break;
535-
pr_debug("pid(%d) page[%d]->count=%d\n",
536-
current->pid, i, page_count(page));
537-
SetPageUptodate(page);
538-
unlock_page(page);
539538

540-
ctx->ring_pages[i] = page;
539+
pr_debug("pid(%d) [%d] folio->count=%d\n", current->pid, i,
540+
folio_ref_count(folio));
541+
folio_end_read(folio, true);
542+
543+
ctx->ring_folios[i] = folio;
541544
}
542545
ctx->nr_pages = i;
543546

@@ -570,15 +573,15 @@ static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events)
570573
ctx->user_id = ctx->mmap_base;
571574
ctx->nr_events = nr_events; /* trusted copy */
572575

573-
ring = page_address(ctx->ring_pages[0]);
576+
ring = folio_address(ctx->ring_folios[0]);
574577
ring->nr = nr_events; /* user copy */
575578
ring->id = ~0U;
576579
ring->head = ring->tail = 0;
577580
ring->magic = AIO_RING_MAGIC;
578581
ring->compat_features = AIO_RING_COMPAT_FEATURES;
579582
ring->incompat_features = AIO_RING_INCOMPAT_FEATURES;
580583
ring->header_length = sizeof(struct aio_ring);
581-
flush_dcache_page(ctx->ring_pages[0]);
584+
flush_dcache_folio(ctx->ring_folios[0]);
582585

583586
return 0;
584587
}
@@ -689,9 +692,9 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
689692

690693
/* While kioctx setup is in progress,
691694
* we are protected from page migration
692-
* changes ring_pages by ->ring_lock.
695+
* changes ring_folios by ->ring_lock.
693696
*/
694-
ring = page_address(ctx->ring_pages[0]);
697+
ring = folio_address(ctx->ring_folios[0]);
695698
ring->id = ctx->id;
696699
return 0;
697700
}
@@ -1033,7 +1036,7 @@ static void user_refill_reqs_available(struct kioctx *ctx)
10331036
* against ctx->completed_events below will make sure we do the
10341037
* safe/right thing.
10351038
*/
1036-
ring = page_address(ctx->ring_pages[0]);
1039+
ring = folio_address(ctx->ring_folios[0]);
10371040
head = ring->head;
10381041

10391042
refill_reqs_available(ctx, head, ctx->tail);
@@ -1145,12 +1148,12 @@ static void aio_complete(struct aio_kiocb *iocb)
11451148
if (++tail >= ctx->nr_events)
11461149
tail = 0;
11471150

1148-
ev_page = page_address(ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE]);
1151+
ev_page = folio_address(ctx->ring_folios[pos / AIO_EVENTS_PER_PAGE]);
11491152
event = ev_page + pos % AIO_EVENTS_PER_PAGE;
11501153

11511154
*event = iocb->ki_res;
11521155

1153-
flush_dcache_page(ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE]);
1156+
flush_dcache_folio(ctx->ring_folios[pos / AIO_EVENTS_PER_PAGE]);
11541157

11551158
pr_debug("%p[%u]: %p: %p %Lx %Lx %Lx\n", ctx, tail, iocb,
11561159
(void __user *)(unsigned long)iocb->ki_res.obj,
@@ -1163,10 +1166,10 @@ static void aio_complete(struct aio_kiocb *iocb)
11631166

11641167
ctx->tail = tail;
11651168

1166-
ring = page_address(ctx->ring_pages[0]);
1169+
ring = folio_address(ctx->ring_folios[0]);
11671170
head = ring->head;
11681171
ring->tail = tail;
1169-
flush_dcache_page(ctx->ring_pages[0]);
1172+
flush_dcache_folio(ctx->ring_folios[0]);
11701173

11711174
ctx->completed_events++;
11721175
if (ctx->completed_events > 1)
@@ -1238,8 +1241,8 @@ static long aio_read_events_ring(struct kioctx *ctx,
12381241
sched_annotate_sleep();
12391242
mutex_lock(&ctx->ring_lock);
12401243

1241-
/* Access to ->ring_pages here is protected by ctx->ring_lock. */
1242-
ring = page_address(ctx->ring_pages[0]);
1244+
/* Access to ->ring_folios here is protected by ctx->ring_lock. */
1245+
ring = folio_address(ctx->ring_folios[0]);
12431246
head = ring->head;
12441247
tail = ring->tail;
12451248

@@ -1260,20 +1263,20 @@ static long aio_read_events_ring(struct kioctx *ctx,
12601263
while (ret < nr) {
12611264
long avail;
12621265
struct io_event *ev;
1263-
struct page *page;
1266+
struct folio *folio;
12641267

12651268
avail = (head <= tail ? tail : ctx->nr_events) - head;
12661269
if (head == tail)
12671270
break;
12681271

12691272
pos = head + AIO_EVENTS_OFFSET;
1270-
page = ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE];
1273+
folio = ctx->ring_folios[pos / AIO_EVENTS_PER_PAGE];
12711274
pos %= AIO_EVENTS_PER_PAGE;
12721275

12731276
avail = min(avail, nr - ret);
12741277
avail = min_t(long, avail, AIO_EVENTS_PER_PAGE - pos);
12751278

1276-
ev = page_address(page);
1279+
ev = folio_address(folio);
12771280
copy_ret = copy_to_user(event + ret, ev + pos,
12781281
sizeof(*ev) * avail);
12791282

@@ -1287,9 +1290,9 @@ static long aio_read_events_ring(struct kioctx *ctx,
12871290
head %= ctx->nr_events;
12881291
}
12891292

1290-
ring = page_address(ctx->ring_pages[0]);
1293+
ring = folio_address(ctx->ring_folios[0]);
12911294
ring->head = head;
1292-
flush_dcache_page(ctx->ring_pages[0]);
1295+
flush_dcache_folio(ctx->ring_folios[0]);
12931296

12941297
pr_debug("%li h%u t%u\n", ret, head, tail);
12951298
out:

fs/anon_inodes.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,38 @@ struct file *anon_inode_getfile(const char *name,
148148
}
149149
EXPORT_SYMBOL_GPL(anon_inode_getfile);
150150

151+
/**
152+
* anon_inode_getfile_fmode - creates a new file instance by hooking it up to an
153+
* anonymous inode, and a dentry that describe the "class"
154+
* of the file
155+
*
156+
* @name: [in] name of the "class" of the new file
157+
* @fops: [in] file operations for the new file
158+
* @priv: [in] private data for the new file (will be file's private_data)
159+
* @flags: [in] flags
160+
* @f_mode: [in] fmode
161+
*
162+
* Creates a new file by hooking it on a single inode. This is useful for files
163+
* that do not need to have a full-fledged inode in order to operate correctly.
164+
* All the files created with anon_inode_getfile() will share a single inode,
165+
* hence saving memory and avoiding code duplication for the file/inode/dentry
166+
* setup. Allows setting the fmode. Returns the newly created file* or an error
167+
* pointer.
168+
*/
169+
struct file *anon_inode_getfile_fmode(const char *name,
170+
const struct file_operations *fops,
171+
void *priv, int flags, fmode_t f_mode)
172+
{
173+
struct file *file;
174+
175+
file = __anon_inode_getfile(name, fops, priv, flags, NULL, false);
176+
if (!IS_ERR(file))
177+
file->f_mode |= f_mode;
178+
179+
return file;
180+
}
181+
EXPORT_SYMBOL_GPL(anon_inode_getfile_fmode);
182+
151183
/**
152184
* anon_inode_create_getfile - Like anon_inode_getfile(), but creates a new
153185
* !S_PRIVATE anon inode rather than reuse the
@@ -271,6 +303,7 @@ int anon_inode_create_getfd(const char *name, const struct file_operations *fops
271303
return __anon_inode_getfd(name, fops, priv, flags, context_inode, true);
272304
}
273305

306+
274307
static int __init anon_inode_init(void)
275308
{
276309
anon_inode_mnt = kern_mount(&anon_inode_fs_type);

fs/bcachefs/fs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,9 @@ static int bch2_getattr(struct mnt_idmap *idmap,
844844
stat->blksize = block_bytes(c);
845845
stat->blocks = inode->v.i_blocks;
846846

847+
stat->subvol = inode->ei_subvol;
848+
stat->result_mask |= STATX_SUBVOL;
849+
847850
if (request_mask & STATX_BTIME) {
848851
stat->result_mask |= STATX_BTIME;
849852
stat->btime = bch2_time_to_timespec(c, inode->ei_inode.bi_otime);

fs/btrfs/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3719,8 +3719,7 @@ static int btrfs_file_open(struct inode *inode, struct file *filp)
37193719
{
37203720
int ret;
37213721

3722-
filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_BUF_WASYNC |
3723-
FMODE_CAN_ODIRECT;
3722+
filp->f_mode |= FMODE_NOWAIT | FMODE_CAN_ODIRECT;
37243723

37253724
ret = fsverity_file_open(inode, filp);
37263725
if (ret)
@@ -3850,6 +3849,7 @@ const struct file_operations btrfs_file_operations = {
38503849
.compat_ioctl = btrfs_compat_ioctl,
38513850
#endif
38523851
.remap_file_range = btrfs_remap_file_range,
3852+
.fop_flags = FOP_BUFFER_RASYNC | FOP_BUFFER_WASYNC,
38533853
};
38543854

38553855
int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end)

fs/btrfs/inode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8789,6 +8789,9 @@ static int btrfs_getattr(struct mnt_idmap *idmap,
87898789
generic_fillattr(idmap, request_mask, inode, stat);
87908790
stat->dev = BTRFS_I(inode)->root->anon_dev;
87918791

8792+
stat->subvol = BTRFS_I(inode)->root->root_key.objectid;
8793+
stat->result_mask |= STATX_SUBVOL;
8794+
87928795
spin_lock(&BTRFS_I(inode)->lock);
87938796
delalloc_bytes = BTRFS_I(inode)->new_delalloc_bytes;
87948797
inode_bytes = inode_get_bytes(inode);

fs/dcache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static inline void __d_clear_type_and_inode(struct dentry *dentry)
355355
flags &= ~DCACHE_ENTRY_TYPE;
356356
WRITE_ONCE(dentry->d_flags, flags);
357357
dentry->d_inode = NULL;
358-
if (dentry->d_flags & DCACHE_LRU_LIST)
358+
if (flags & DCACHE_LRU_LIST)
359359
this_cpu_inc(nr_dentry_negative);
360360
}
361361

0 commit comments

Comments
 (0)