Skip to content

Commit 60ef1e9

Browse files
terraluna977eafer
authored andcommitted
Building on kernel 6.8
[eafer: moved bdev handle to the container superblock]
1 parent 0313a0f commit 60ef1e9

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

apfs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ struct apfs_ephemeral_object_info {
230230
*/
231231
struct apfs_nxsb_info {
232232
struct block_device *nx_bdev; /* Device for the container */
233+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
234+
struct bdev_handle *nx_bdev_handle;
235+
#endif
233236
struct apfs_nx_superblock *nx_raw; /* On-disk main sb */
234237
u64 nx_bno; /* Current block number for the checkpoint superblock */
235238
u64 nx_xid; /* Latest transaction id */

file.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
#include "apfs.h"
77

8+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
9+
#include <linux/splice.h>
10+
#endif
811
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0)
912
typedef int vm_fault_t;
1013
#endif
@@ -152,6 +155,16 @@ int apfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
152155
return apfs_sync_fs(sb, true /* wait */);
153156
}
154157

158+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
159+
static ssize_t apfs_copy_file_range(struct file *src_file, loff_t src_off,
160+
struct file *dst_file, loff_t dst_off,
161+
size_t len, unsigned int flags)
162+
{
163+
return (splice_copy_file_range(src_file, src_off,
164+
dst_file, dst_off, len));
165+
}
166+
#endif
167+
155168
const struct file_operations apfs_file_operations = {
156169
.llseek = generic_file_llseek,
157170
.read_iter = generic_file_read_iter,
@@ -161,7 +174,9 @@ const struct file_operations apfs_file_operations = {
161174
.fsync = apfs_fsync,
162175
.unlocked_ioctl = apfs_file_ioctl,
163176

164-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)
177+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
178+
.copy_file_range = apfs_copy_file_range,
179+
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)
165180
.copy_file_range = generic_copy_file_range,
166181
#endif
167182

super.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ static inline void apfs_free_main_super(struct apfs_sb_info *sbi)
322322
kfree(nxi->nx_raw);
323323
nxi->nx_raw = NULL;
324324

325-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
325+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
326+
bdev_release(nxi->nx_bdev_handle);
327+
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
326328
blkdev_put(nxi->nx_bdev, &apfs_fs_type);
327329
#else
328330
blkdev_put(nxi->nx_bdev, mode);
@@ -1581,13 +1583,24 @@ static int apfs_attach_nxi(struct apfs_sb_info *sbi, const char *dev_name, fmode
15811583

15821584
nxi = apfs_nx_find_by_dev(dev);
15831585
if (!nxi) {
1586+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
1587+
struct bdev_handle *handle;
1588+
#endif
15841589
struct block_device *bdev;
15851590

15861591
nxi = kzalloc(sizeof(*nxi), GFP_KERNEL);
15871592
if (!nxi)
15881593
return -ENOMEM;
15891594

1590-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
1595+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
1596+
handle = bdev_open_by_path(dev_name, mode, &apfs_fs_type, NULL);
1597+
if (IS_ERR(handle)) {
1598+
kfree(nxi);
1599+
return PTR_ERR(handle);
1600+
}
1601+
nxi->nx_bdev_handle = handle;
1602+
bdev = handle->bdev;
1603+
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
15911604
bdev = blkdev_get_by_path(dev_name, mode, &apfs_fs_type, NULL);
15921605
#else
15931606
bdev = blkdev_get_by_path(dev_name, mode, &apfs_fs_type);

0 commit comments

Comments
 (0)