@@ -341,77 +341,6 @@ static loff_t zonefs_file_llseek(struct file *file, loff_t offset, int whence)
341
341
return generic_file_llseek_size (file , offset , whence , isize , isize );
342
342
}
343
343
344
- struct zonefs_zone_append_bio {
345
- /* The target inode of the BIO */
346
- struct inode * inode ;
347
-
348
- /* For sync writes, the target append write offset */
349
- u64 append_offset ;
350
-
351
- /*
352
- * This member must come last, bio_alloc_bioset will allocate enough
353
- * bytes for entire zonefs_bio but relies on bio being last.
354
- */
355
- struct bio bio ;
356
- };
357
-
358
- static inline struct zonefs_zone_append_bio *
359
- zonefs_zone_append_bio (struct bio * bio )
360
- {
361
- return container_of (bio , struct zonefs_zone_append_bio , bio );
362
- }
363
-
364
- static void zonefs_file_zone_append_dio_bio_end_io (struct bio * bio )
365
- {
366
- struct zonefs_zone_append_bio * za_bio = zonefs_zone_append_bio (bio );
367
- struct zonefs_zone * z = zonefs_inode_zone (za_bio -> inode );
368
- sector_t za_sector ;
369
-
370
- if (bio -> bi_status != BLK_STS_OK )
371
- goto bio_end ;
372
-
373
- /*
374
- * If the file zone was written underneath the file system, the zone
375
- * append operation can still succedd (if the zone is not full) but
376
- * the write append location will not be where we expect it to be.
377
- * Check that we wrote where we intended to, that is, at z->z_wpoffset.
378
- */
379
- za_sector = z -> z_sector + (za_bio -> append_offset >> SECTOR_SHIFT );
380
- if (bio -> bi_iter .bi_sector != za_sector ) {
381
- zonefs_warn (za_bio -> inode -> i_sb ,
382
- "Invalid write sector %llu for zone at %llu\n" ,
383
- bio -> bi_iter .bi_sector , z -> z_sector );
384
- bio -> bi_status = BLK_STS_IOERR ;
385
- }
386
-
387
- bio_end :
388
- iomap_dio_bio_end_io (bio );
389
- }
390
-
391
- static void zonefs_file_zone_append_dio_submit_io (const struct iomap_iter * iter ,
392
- struct bio * bio ,
393
- loff_t file_offset )
394
- {
395
- struct zonefs_zone_append_bio * za_bio = zonefs_zone_append_bio (bio );
396
- struct inode * inode = iter -> inode ;
397
- struct zonefs_zone * z = zonefs_inode_zone (inode );
398
-
399
- /*
400
- * Issue a zone append BIO to process sync dio writes. The append
401
- * file offset is saved to check the zone append write location
402
- * on completion of the BIO.
403
- */
404
- za_bio -> inode = inode ;
405
- za_bio -> append_offset = file_offset ;
406
-
407
- bio -> bi_opf &= ~REQ_OP_WRITE ;
408
- bio -> bi_opf |= REQ_OP_ZONE_APPEND ;
409
- bio -> bi_iter .bi_sector = z -> z_sector ;
410
- bio -> bi_end_io = zonefs_file_zone_append_dio_bio_end_io ;
411
-
412
- submit_bio (bio );
413
- }
414
-
415
344
static int zonefs_file_write_dio_end_io (struct kiocb * iocb , ssize_t size ,
416
345
int error , unsigned int flags )
417
346
{
@@ -442,14 +371,6 @@ static int zonefs_file_write_dio_end_io(struct kiocb *iocb, ssize_t size,
442
371
return 0 ;
443
372
}
444
373
445
- static struct bio_set zonefs_zone_append_bio_set ;
446
-
447
- static const struct iomap_dio_ops zonefs_zone_append_dio_ops = {
448
- .submit_io = zonefs_file_zone_append_dio_submit_io ,
449
- .end_io = zonefs_file_write_dio_end_io ,
450
- .bio_set = & zonefs_zone_append_bio_set ,
451
- };
452
-
453
374
static const struct iomap_dio_ops zonefs_write_dio_ops = {
454
375
.end_io = zonefs_file_write_dio_end_io ,
455
376
};
@@ -533,17 +454,15 @@ static ssize_t zonefs_file_dio_write(struct kiocb *iocb, struct iov_iter *from)
533
454
struct zonefs_inode_info * zi = ZONEFS_I (inode );
534
455
struct zonefs_zone * z = zonefs_inode_zone (inode );
535
456
struct super_block * sb = inode -> i_sb ;
536
- const struct iomap_dio_ops * dio_ops ;
537
- bool sync = is_sync_kiocb (iocb );
538
- bool append = false;
539
457
ssize_t ret , count ;
540
458
541
459
/*
542
460
* For async direct IOs to sequential zone files, refuse IOCB_NOWAIT
543
461
* as this can cause write reordering (e.g. the first aio gets EAGAIN
544
462
* on the inode lock but the second goes through but is now unaligned).
545
463
*/
546
- if (zonefs_zone_is_seq (z ) && !sync && (iocb -> ki_flags & IOCB_NOWAIT ))
464
+ if (zonefs_zone_is_seq (z ) && !is_sync_kiocb (iocb ) &&
465
+ (iocb -> ki_flags & IOCB_NOWAIT ))
547
466
return - EOPNOTSUPP ;
548
467
549
468
if (iocb -> ki_flags & IOCB_NOWAIT ) {
@@ -573,18 +492,6 @@ static ssize_t zonefs_file_dio_write(struct kiocb *iocb, struct iov_iter *from)
573
492
goto inode_unlock ;
574
493
}
575
494
mutex_unlock (& zi -> i_truncate_mutex );
576
- append = sync ;
577
- }
578
-
579
- if (append ) {
580
- unsigned int max = bdev_max_zone_append_sectors (sb -> s_bdev );
581
-
582
- max = ALIGN_DOWN (max << SECTOR_SHIFT , sb -> s_blocksize );
583
- iov_iter_truncate (from , max );
584
-
585
- dio_ops = & zonefs_zone_append_dio_ops ;
586
- } else {
587
- dio_ops = & zonefs_write_dio_ops ;
588
495
}
589
496
590
497
/*
@@ -593,7 +500,7 @@ static ssize_t zonefs_file_dio_write(struct kiocb *iocb, struct iov_iter *from)
593
500
* the user can make sense of the error.
594
501
*/
595
502
ret = iomap_dio_rw (iocb , from , & zonefs_write_iomap_ops ,
596
- dio_ops , 0 , NULL , 0 );
503
+ & zonefs_write_dio_ops , 0 , NULL , 0 );
597
504
if (ret == - ENOTBLK )
598
505
ret = - EBUSY ;
599
506
@@ -938,15 +845,3 @@ const struct file_operations zonefs_file_operations = {
938
845
.splice_write = iter_file_splice_write ,
939
846
.iopoll = iocb_bio_iopoll ,
940
847
};
941
-
942
- int zonefs_file_bioset_init (void )
943
- {
944
- return bioset_init (& zonefs_zone_append_bio_set , BIO_POOL_SIZE ,
945
- offsetof(struct zonefs_zone_append_bio , bio ),
946
- BIOSET_NEED_BVECS );
947
- }
948
-
949
- void zonefs_file_bioset_exit (void )
950
- {
951
- bioset_exit (& zonefs_zone_append_bio_set );
952
- }
0 commit comments