@@ -77,8 +77,7 @@ static int zonefs_write_iomap_begin(struct inode *inode, loff_t offset,
77
77
* checked when writes are issued, so warn if we see a page writeback
78
78
* operation.
79
79
*/
80
- if (WARN_ON_ONCE (zi -> i_ztype == ZONEFS_ZTYPE_SEQ &&
81
- !(flags & IOMAP_DIRECT )))
80
+ if (WARN_ON_ONCE (zonefs_zone_is_seq (zi ) && !(flags & IOMAP_DIRECT )))
82
81
return - EIO ;
83
82
84
83
/*
@@ -128,7 +127,7 @@ static int zonefs_write_map_blocks(struct iomap_writepage_ctx *wpc,
128
127
{
129
128
struct zonefs_inode_info * zi = ZONEFS_I (inode );
130
129
131
- if (WARN_ON_ONCE (zi -> i_ztype != ZONEFS_ZTYPE_CNV ))
130
+ if (WARN_ON_ONCE (zonefs_zone_is_seq ( zi ) ))
132
131
return - EIO ;
133
132
if (WARN_ON_ONCE (offset >= i_size_read (inode )))
134
133
return - EIO ;
@@ -158,9 +157,8 @@ static int zonefs_swap_activate(struct swap_info_struct *sis,
158
157
struct file * swap_file , sector_t * span )
159
158
{
160
159
struct inode * inode = file_inode (swap_file );
161
- struct zonefs_inode_info * zi = ZONEFS_I (inode );
162
160
163
- if (zi -> i_ztype != ZONEFS_ZTYPE_CNV ) {
161
+ if (zonefs_inode_is_seq ( inode ) ) {
164
162
zonefs_err (inode -> i_sb ,
165
163
"swap file: not a conventional zone file\n" );
166
164
return - EINVAL ;
@@ -196,7 +194,7 @@ int zonefs_file_truncate(struct inode *inode, loff_t isize)
196
194
* only down to a 0 size, which is equivalent to a zone reset, and to
197
195
* the maximum file size, which is equivalent to a zone finish.
198
196
*/
199
- if (zi -> i_ztype != ZONEFS_ZTYPE_SEQ )
197
+ if (! zonefs_zone_is_seq ( zi ) )
200
198
return - EPERM ;
201
199
202
200
if (!isize )
@@ -266,7 +264,7 @@ static int zonefs_file_fsync(struct file *file, loff_t start, loff_t end,
266
264
* Since only direct writes are allowed in sequential files, page cache
267
265
* flush is needed only for conventional zone files.
268
266
*/
269
- if (ZONEFS_I (inode )-> i_ztype == ZONEFS_ZTYPE_CNV )
267
+ if (zonefs_inode_is_cnv (inode ))
270
268
ret = file_write_and_wait_range (file , start , end );
271
269
if (!ret )
272
270
ret = blkdev_issue_flush (inode -> i_sb -> s_bdev );
@@ -280,7 +278,6 @@ static int zonefs_file_fsync(struct file *file, loff_t start, loff_t end,
280
278
static vm_fault_t zonefs_filemap_page_mkwrite (struct vm_fault * vmf )
281
279
{
282
280
struct inode * inode = file_inode (vmf -> vma -> vm_file );
283
- struct zonefs_inode_info * zi = ZONEFS_I (inode );
284
281
vm_fault_t ret ;
285
282
286
283
if (unlikely (IS_IMMUTABLE (inode )))
@@ -290,7 +287,7 @@ static vm_fault_t zonefs_filemap_page_mkwrite(struct vm_fault *vmf)
290
287
* Sanity check: only conventional zone files can have shared
291
288
* writeable mappings.
292
289
*/
293
- if (WARN_ON_ONCE ( zi -> i_ztype != ZONEFS_ZTYPE_CNV ))
290
+ if (zonefs_inode_is_seq ( inode ))
294
291
return VM_FAULT_NOPAGE ;
295
292
296
293
sb_start_pagefault (inode -> i_sb );
@@ -319,7 +316,7 @@ static int zonefs_file_mmap(struct file *file, struct vm_area_struct *vma)
319
316
* mappings are possible since there are no guarantees for write
320
317
* ordering between msync() and page cache writeback.
321
318
*/
322
- if (ZONEFS_I (file_inode (file ))-> i_ztype == ZONEFS_ZTYPE_SEQ &&
319
+ if (zonefs_inode_is_seq (file_inode (file )) &&
323
320
(vma -> vm_flags & VM_SHARED ) && (vma -> vm_flags & VM_MAYWRITE ))
324
321
return - EINVAL ;
325
322
@@ -352,7 +349,7 @@ static int zonefs_file_write_dio_end_io(struct kiocb *iocb, ssize_t size,
352
349
return error ;
353
350
}
354
351
355
- if (size && zi -> i_ztype != ZONEFS_ZTYPE_CNV ) {
352
+ if (size && zonefs_zone_is_seq ( zi ) ) {
356
353
/*
357
354
* Note that we may be seeing completions out of order,
358
355
* but that is not a problem since a write completed
@@ -491,7 +488,7 @@ static ssize_t zonefs_write_checks(struct kiocb *iocb, struct iov_iter *from)
491
488
return - EINVAL ;
492
489
493
490
if (iocb -> ki_flags & IOCB_APPEND ) {
494
- if (zi -> i_ztype != ZONEFS_ZTYPE_SEQ )
491
+ if (zonefs_zone_is_cnv ( zi ) )
495
492
return - EINVAL ;
496
493
mutex_lock (& zi -> i_truncate_mutex );
497
494
iocb -> ki_pos = zi -> i_wpoffset ;
@@ -531,8 +528,7 @@ static ssize_t zonefs_file_dio_write(struct kiocb *iocb, struct iov_iter *from)
531
528
* as this can cause write reordering (e.g. the first aio gets EAGAIN
532
529
* on the inode lock but the second goes through but is now unaligned).
533
530
*/
534
- if (zi -> i_ztype == ZONEFS_ZTYPE_SEQ && !sync &&
535
- (iocb -> ki_flags & IOCB_NOWAIT ))
531
+ if (zonefs_zone_is_seq (zi ) && !sync && (iocb -> ki_flags & IOCB_NOWAIT ))
536
532
return - EOPNOTSUPP ;
537
533
538
534
if (iocb -> ki_flags & IOCB_NOWAIT ) {
@@ -554,7 +550,7 @@ static ssize_t zonefs_file_dio_write(struct kiocb *iocb, struct iov_iter *from)
554
550
}
555
551
556
552
/* Enforce sequential writes (append only) in sequential zones */
557
- if (zi -> i_ztype == ZONEFS_ZTYPE_SEQ ) {
553
+ if (zonefs_zone_is_seq ( zi ) ) {
558
554
mutex_lock (& zi -> i_truncate_mutex );
559
555
if (iocb -> ki_pos != zi -> i_wpoffset ) {
560
556
mutex_unlock (& zi -> i_truncate_mutex );
@@ -570,7 +566,7 @@ static ssize_t zonefs_file_dio_write(struct kiocb *iocb, struct iov_iter *from)
570
566
else
571
567
ret = iomap_dio_rw (iocb , from , & zonefs_write_iomap_ops ,
572
568
& zonefs_write_dio_ops , 0 , NULL , 0 );
573
- if (zi -> i_ztype == ZONEFS_ZTYPE_SEQ &&
569
+ if (zonefs_zone_is_seq ( zi ) &&
574
570
(ret > 0 || ret == - EIOCBQUEUED )) {
575
571
if (ret > 0 )
576
572
count = ret ;
@@ -596,14 +592,13 @@ static ssize_t zonefs_file_buffered_write(struct kiocb *iocb,
596
592
struct iov_iter * from )
597
593
{
598
594
struct inode * inode = file_inode (iocb -> ki_filp );
599
- struct zonefs_inode_info * zi = ZONEFS_I (inode );
600
595
ssize_t ret ;
601
596
602
597
/*
603
598
* Direct IO writes are mandatory for sequential zone files so that the
604
599
* write IO issuing order is preserved.
605
600
*/
606
- if (zi -> i_ztype != ZONEFS_ZTYPE_CNV )
601
+ if (zonefs_inode_is_seq ( inode ) )
607
602
return - EIO ;
608
603
609
604
if (iocb -> ki_flags & IOCB_NOWAIT ) {
@@ -731,9 +726,7 @@ static ssize_t zonefs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
731
726
static inline bool zonefs_seq_file_need_wro (struct inode * inode ,
732
727
struct file * file )
733
728
{
734
- struct zonefs_inode_info * zi = ZONEFS_I (inode );
735
-
736
- if (zi -> i_ztype != ZONEFS_ZTYPE_SEQ )
729
+ if (zonefs_inode_is_cnv (inode ))
737
730
return false;
738
731
739
732
if (!(file -> f_mode & FMODE_WRITE ))
0 commit comments