@@ -476,6 +476,9 @@ int __apfs_write_begin(struct file *file, struct address_space *mapping, loff_t
476
476
struct apfs_dstream_info * dstream = & APFS_I (inode )-> i_dstream ;
477
477
struct super_block * sb = inode -> i_sb ;
478
478
struct page * page ;
479
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION (6 , 7 , 0 )
480
+ struct folio * folio ;
481
+ #endif
479
482
struct buffer_head * bh , * head ;
480
483
unsigned int blocksize , block_start , block_end , from , to ;
481
484
pgoff_t index = pos >> PAGE_SHIFT ;
@@ -508,8 +511,16 @@ int __apfs_write_begin(struct file *file, struct address_space *mapping, loff_t
508
511
#endif
509
512
if (!page )
510
513
return - ENOMEM ;
511
- if (!page_has_buffers (page ))
514
+ if (!page_has_buffers (page )) {
515
+ #if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 7 , 0 )
512
516
create_empty_buffers (page , sb -> s_blocksize , 0 );
517
+ #else
518
+ folio = page_folio (page );
519
+ bh = folio_buffers (folio );
520
+ if (!bh )
521
+ bh = create_empty_buffers (folio , sb -> s_blocksize , 0 );
522
+ #endif
523
+ }
513
524
514
525
/* CoW moves existing blocks, so read them but mark them as unmapped */
515
526
head = page_buffers (page );
@@ -787,13 +798,19 @@ static int apfs_inode_from_query(struct apfs_query *query, struct inode *inode)
787
798
ai -> i_nchildren = le32_to_cpu (inode_val -> nchildren );
788
799
}
789
800
790
- inode -> i_atime = ns_to_timespec64 (le64_to_cpu (inode_val -> access_time ));
791
801
#if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 6 , 0 )
792
802
inode -> i_ctime = ns_to_timespec64 (le64_to_cpu (inode_val -> change_time ));
793
803
#else
794
804
inode_set_ctime_to_ts (inode , ns_to_timespec64 (le64_to_cpu (inode_val -> change_time )));
795
805
#endif
806
+
807
+ #if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 7 , 0 )
808
+ inode -> i_atime = ns_to_timespec64 (le64_to_cpu (inode_val -> access_time ));
796
809
inode -> i_mtime = ns_to_timespec64 (le64_to_cpu (inode_val -> mod_time ));
810
+ #else
811
+ inode_set_atime_to_ts (inode , ns_to_timespec64 (le64_to_cpu (inode_val -> access_time )));
812
+ inode_set_mtime_to_ts (inode , ns_to_timespec64 (le64_to_cpu (inode_val -> mod_time )));
813
+ #endif
797
814
ai -> i_crtime = ns_to_timespec64 (le64_to_cpu (inode_val -> create_time ));
798
815
799
816
dstream -> ds_size = inode -> i_size = inode -> i_blocks = 0 ;
@@ -1097,6 +1114,9 @@ static int apfs_build_inode_val(struct inode *inode, struct qstr *qname,
1097
1114
{
1098
1115
struct apfs_inode_val * val ;
1099
1116
struct apfs_x_field xkey ;
1117
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION (6 , 7 , 0 )
1118
+ struct timespec64 ts ;
1119
+ #endif
1100
1120
int total_xlen , val_len ;
1101
1121
bool is_device = S_ISCHR (inode -> i_mode ) || S_ISBLK (inode -> i_mode );
1102
1122
__le32 rdev ;
@@ -1115,7 +1135,12 @@ static int apfs_build_inode_val(struct inode *inode, struct qstr *qname,
1115
1135
val -> parent_id = cpu_to_le64 (APFS_I (inode )-> i_parent_id );
1116
1136
val -> private_id = cpu_to_le64 (apfs_ino (inode ));
1117
1137
1138
+ #if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 7 , 0 )
1118
1139
val -> mod_time = cpu_to_le64 (timespec64_to_ns (& inode -> i_mtime ));
1140
+ #else
1141
+ ts = inode_get_mtime (inode );
1142
+ val -> mod_time = cpu_to_le64 (timespec64_to_ns (& ts ));
1143
+ #endif
1119
1144
val -> create_time = val -> change_time = val -> access_time = val -> mod_time ;
1120
1145
1121
1146
if (S_ISDIR (inode -> i_mode ))
@@ -1477,14 +1502,22 @@ int apfs_update_inode(struct inode *inode, char *new_name)
1477
1502
if (gid_valid (sbi -> s_gid ))
1478
1503
inode_raw -> group = cpu_to_le32 (ai -> i_saved_gid );
1479
1504
1480
- inode_raw -> access_time = cpu_to_le64 (timespec64_to_ns (& inode -> i_atime ));
1481
1505
#if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 6 , 0 )
1482
1506
inode_raw -> change_time = cpu_to_le64 (timespec64_to_ns (& inode -> i_ctime ));
1483
1507
#else
1484
1508
struct timespec64 ictime = inode_get_ctime (inode );
1485
1509
inode_raw -> change_time = cpu_to_le64 (timespec64_to_ns (& ictime ));
1486
1510
#endif
1511
+
1512
+ #if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 7 , 0 )
1513
+ inode_raw -> access_time = cpu_to_le64 (timespec64_to_ns (& inode -> i_atime ));
1487
1514
inode_raw -> mod_time = cpu_to_le64 (timespec64_to_ns (& inode -> i_mtime ));
1515
+ #else
1516
+ struct timespec64 ts = inode_get_mtime (inode );
1517
+ inode_raw -> mod_time = cpu_to_le64 (timespec64_to_ns (& ts ));
1518
+ ts = inode_get_atime (inode );
1519
+ inode_raw -> access_time = cpu_to_le64 (timespec64_to_ns (& ts ));
1520
+ #endif
1488
1521
inode_raw -> create_time = cpu_to_le64 (timespec64_to_ns (& ai -> i_crtime ));
1489
1522
1490
1523
if (S_ISDIR (inode -> i_mode )) {
@@ -1665,9 +1698,11 @@ struct inode *apfs_new_inode(struct inode *dir, umode_t mode, dev_t rdev)
1665
1698
now = current_time (inode );
1666
1699
#if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 6 , 0 )
1667
1700
inode -> i_atime = inode -> i_mtime = inode -> i_ctime = ai -> i_crtime = now ;
1668
- #else
1701
+ #elif LINUX_VERSION_CODE < KERNEL_VERSION ( 6 , 7 , 0 )
1669
1702
inode_set_ctime_to_ts (inode , now );
1670
1703
inode -> i_atime = inode -> i_mtime = ai -> i_crtime = now ;
1704
+ #else
1705
+ ai -> i_crtime = simple_inode_init_ts (inode );
1671
1706
#endif
1672
1707
vsb_raw -> apfs_last_mod_time = cpu_to_le64 (timespec64_to_ns (& now ));
1673
1708
@@ -1762,8 +1797,10 @@ static int apfs_setsize(struct inode *inode, loff_t new_size)
1762
1797
return 0 ;
1763
1798
#if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 6 , 0 )
1764
1799
inode -> i_mtime = inode -> i_ctime = current_time (inode );
1765
- #else
1800
+ #elif LINUX_VERSION_CODE < KERNEL_VERSION ( 6 , 7 , 0 )
1766
1801
inode -> i_mtime = inode_set_ctime_current (inode );
1802
+ #else
1803
+ inode_set_mtime_to_ts (inode , inode_set_ctime_current (inode ));
1767
1804
#endif
1768
1805
1769
1806
err = apfs_inode_create_dstream_rec (inode );
0 commit comments