Skip to content

Commit

Permalink
exfat: changes the minimum supported kernel version from 4.10 to 5.15
Browse files Browse the repository at this point in the history
Backporting new patches to the 4.x kernel has become difficult. The existing 4.x support version was made into a branch of for-kernel-version-from-4.1.0.

Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
namjaejeon committed Dec 1, 2023
1 parent 3ad1490 commit 12bc545
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 720 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install libelf-dev wget tar gzip python2.7
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.1.36.tar.gz
tar xf linux-4.1.36.tar.gz
mv linux-4.1.36 linux-stable
rm -rf linux-4.1.36.tar.gz
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.15.140.tar.gz
tar xf linux-5.15.140.tar.gz
mv linux-5.15.140 linux-stable
rm -rf linux-5.15.140.tar.gz
- name: Prerequisite for xfstests testing
run: |
sudo apt-get install linux-headers-$(uname -r)
Expand All @@ -35,9 +35,8 @@ jobs:
- name: Copy exfat source to kernel
run: |
mv linux-stable ../
mkdir ../linux-stable/fs/exfat
cp -ar * ../linux-stable/fs/exfat/
- name: Compile with 4.1 kernel
- name: Compile with 5.15 kernel
run: |
cd ../linux-stable
yes "" | make oldconfig > /dev/null
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## exFAT filesystem
This is the exfat filesystem for support from the linux 4.1 kernel
This is the exfat filesystem for support from the linux 5.15 kernel
to the latest kernel.

## Installing as a stand-alone module
Expand Down
8 changes: 0 additions & 8 deletions balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
#include <linux/blkdev.h>
#include <linux/slab.h>
#include <linux/buffer_head.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
#include <linux/sched/signal.h>
#else
#include <linux/sched.h>
#endif
#include <linux/vmalloc.h>

#include "exfat_raw.h"
Expand Down Expand Up @@ -76,12 +72,8 @@ static int exfat_allocate_bitmap(struct super_block *sb,
}
sbi->map_sectors = ((need_map_size - 1) >>
(sb->s_blocksize_bits)) + 1;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
sbi->vol_amap = kvmalloc_array(sbi->map_sectors,
sizeof(struct buffer_head *), GFP_KERNEL);
#else
sbi->vol_amap = vmalloc(sbi->map_sectors * sizeof(struct buffer_head *));
#endif
if (!sbi->vol_amap)
return -ENOMEM;

Expand Down
8 changes: 0 additions & 8 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,19 +461,11 @@ int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir,
{
struct super_block *sb = inode->i_sb;
struct exfat_sb_info *sbi = EXFAT_SB(sb);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
struct timespec64 ts;
#else
struct timespec ts;
#endif
struct exfat_dentry *ep;
struct buffer_head *bh;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
ts = current_time(inode);
#else
ts = CURRENT_TIME_SEC;
#endif

/*
* We cannot use exfat_get_dentry_set here because file ep is not
Expand Down
37 changes: 0 additions & 37 deletions exfat_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,9 @@ struct exfat_dir_entry {
unsigned short attr;
loff_t size;
unsigned int num_subdirs;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
struct timespec64 atime;
struct timespec64 mtime;
struct timespec64 crtime;
#else
struct timespec atime;
struct timespec mtime;
struct timespec crtime;
#endif
struct exfat_dentry_namebuf namebuf;
};

Expand Down Expand Up @@ -344,11 +338,7 @@ struct exfat_inode_info {
struct rw_semaphore truncate_lock;
struct inode vfs_inode;
/* File creation time */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
struct timespec64 i_crtime;
#else
struct timespec i_crtime;
#endif
};

static inline struct exfat_sb_info *EXFAT_SB(struct super_block *sb)
Expand Down Expand Up @@ -478,30 +468,11 @@ extern const struct file_operations exfat_file_operations;
int __exfat_truncate(struct inode *inode);
void exfat_truncate(struct inode *inode);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
int exfat_getattr(struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, unsigned int request_mask,
unsigned int query_flags);
#else
int exfat_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
struct iattr *attr);
int exfat_getattr(struct user_namespace *mnt_userns, const struct path *path,
struct kstat *stat, unsigned int request_mask,
unsigned int query_flags);
#endif
#else
int exfat_setattr(struct dentry *dentry, struct iattr *attr);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
int exfat_getattr(const struct path *path, struct kstat *stat,
unsigned int request_mask, unsigned int query_flags);
#else
int exfat_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *stat);
#endif
#endif
int exfat_file_fsync(struct file *file, loff_t start, loff_t end, int datasync);
long exfat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
long exfat_compat_ioctl(struct file *filp, unsigned int cmd,
Expand Down Expand Up @@ -594,7 +565,6 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
#define exfat_debug(sb, fmt, ...) \
pr_debug("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
u8 tz, __le16 time, __le16 date, u8 time_cs);
void exfat_truncate_atime(struct timespec64 *ts);
Expand All @@ -603,13 +573,6 @@ void exfat_truncate_inode_atime(struct inode *inode);
#endif
void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
u8 *tz, __le16 *time, __le16 *date, u8 *time_cs);
#else
void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec *ts,
u8 tz, __le16 time, __le16 date, u8 time_cs);
void exfat_truncate_atime(struct timespec *ts);
void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec *ts,
u8 *tz, __le16 *time, __le16 *date, u8 *time_cs);
#endif
u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type);
u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type);
void exfat_update_bh(struct buffer_head *bh, int sync);
Expand Down
15 changes: 0 additions & 15 deletions fatent.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ static int exfat_mirror_bh(struct super_block *sb, sector_t sec,
memcpy(c_bh->b_data, bh->b_data, sb->s_blocksize);
set_buffer_uptodate(c_bh);
mark_buffer_dirty(c_bh);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
if (sb->s_flags & SB_SYNCHRONOUS)
#else
if (sb->s_flags & MS_SYNCHRONOUS)
#endif
err = sync_dirty_buffer(c_bh);
brelse(c_bh);
}
Expand Down Expand Up @@ -80,11 +76,7 @@ int exfat_ent_set(struct super_block *sb, unsigned int loc,

fat_entry = (__le32 *)&(bh->b_data[off]);
*fat_entry = cpu_to_le32(content);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
exfat_update_bh(bh, sb->s_flags & SB_SYNCHRONOUS);
#else
exfat_update_bh(bh, sb->s_flags & MS_SYNCHRONOUS);
#endif
exfat_mirror_bh(sb, sec, bh);
brelse(bh);
return 0;
Expand Down Expand Up @@ -304,16 +296,9 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
}

if (IS_DIRSYNC(dir))
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
return sync_blockdev_range(sb->s_bdev,
EXFAT_BLK_TO_B(blknr, sb),
EXFAT_BLK_TO_B(last_blknr, sb) - 1);
#else
return filemap_write_and_wait_range(sb->s_bdev->bd_inode->i_mapping,
EXFAT_BLK_TO_B(blknr, sb),
EXFAT_BLK_TO_B(last_blknr, sb) - 1);
#endif


return 0;
}
Expand Down
Loading

0 comments on commit 12bc545

Please sign in to comment.