@@ -335,35 +335,32 @@ static int fuse_readdir_uncached(struct file *file, struct dir_context *ctx)
335
335
{
336
336
int plus ;
337
337
ssize_t res ;
338
- struct folio * folio ;
339
338
struct inode * inode = file_inode (file );
340
339
struct fuse_mount * fm = get_fuse_mount (inode );
340
+ struct fuse_conn * fc = fm -> fc ;
341
341
struct fuse_io_args ia = {};
342
- struct fuse_args_pages * ap = & ia .ap ;
343
- struct fuse_folio_desc desc = { .length = PAGE_SIZE };
342
+ struct fuse_args * args = & ia .ap .args ;
343
+ void * buf ;
344
+ size_t bufsize = clamp ((unsigned int ) ctx -> count , PAGE_SIZE , fc -> max_pages << PAGE_SHIFT );
344
345
u64 attr_version = 0 , evict_ctr = 0 ;
345
346
bool locked ;
346
347
347
- folio = folio_alloc ( GFP_KERNEL , 0 );
348
- if (!folio )
348
+ buf = kvmalloc ( bufsize , GFP_KERNEL );
349
+ if (!buf )
349
350
return - ENOMEM ;
350
351
352
+ args -> out_args [0 ].value = buf ;
353
+
351
354
plus = fuse_use_readdirplus (inode , ctx );
352
- ap -> args .out_pages = true;
353
- ap -> num_folios = 1 ;
354
- ap -> folios = & folio ;
355
- ap -> descs = & desc ;
356
355
if (plus ) {
357
356
attr_version = fuse_get_attr_version (fm -> fc );
358
357
evict_ctr = fuse_get_evict_ctr (fm -> fc );
359
- fuse_read_args_fill (& ia , file , ctx -> pos , PAGE_SIZE ,
360
- FUSE_READDIRPLUS );
358
+ fuse_read_args_fill (& ia , file , ctx -> pos , bufsize , FUSE_READDIRPLUS );
361
359
} else {
362
- fuse_read_args_fill (& ia , file , ctx -> pos , PAGE_SIZE ,
363
- FUSE_READDIR );
360
+ fuse_read_args_fill (& ia , file , ctx -> pos , bufsize , FUSE_READDIR );
364
361
}
365
362
locked = fuse_lock_inode (inode );
366
- res = fuse_simple_request (fm , & ap -> args );
363
+ res = fuse_simple_request (fm , args );
367
364
fuse_unlock_inode (inode , locked );
368
365
if (res >= 0 ) {
369
366
if (!res ) {
@@ -372,16 +369,14 @@ static int fuse_readdir_uncached(struct file *file, struct dir_context *ctx)
372
369
if (ff -> open_flags & FOPEN_CACHE_DIR )
373
370
fuse_readdir_cache_end (file , ctx -> pos );
374
371
} else if (plus ) {
375
- res = parse_dirplusfile (folio_address (folio ), res ,
376
- file , ctx , attr_version ,
372
+ res = parse_dirplusfile (buf , res , file , ctx , attr_version ,
377
373
evict_ctr );
378
374
} else {
379
- res = parse_dirfile (folio_address (folio ), res , file ,
380
- ctx );
375
+ res = parse_dirfile (buf , res , file , ctx );
381
376
}
382
377
}
383
378
384
- folio_put ( folio );
379
+ kvfree ( buf );
385
380
fuse_invalidate_atime (inode );
386
381
return res ;
387
382
}
0 commit comments