diff --git a/fs/incfs/compat.h b/fs/incfs/compat.h deleted file mode 100644 index f6fd9b2b3cb2..000000000000 --- a/fs/incfs/compat.h +++ /dev/null @@ -1,33 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright 2019 Google LLC - */ -#ifndef _INCFS_COMPAT_H -#define _INCFS_COMPAT_H - -#include -#include - -typedef unsigned int __poll_t; - -#ifndef u64_to_user_ptr -#define u64_to_user_ptr(x) ( \ -{ \ - typecheck(u64, x); \ - (void __user *)(uintptr_t)x; \ -} \ -) -#endif - -#ifndef lru_to_page -#define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) -#endif - -#define readahead_gfp_mask(x) \ - (mapping_gfp_mask(x) | __GFP_NORETRY | __GFP_NOWARN) - -#ifndef SB_ACTIVE -#define SB_ACTIVE MS_ACTIVE -#endif - -#endif /* _INCFS_COMPAT_H */ diff --git a/fs/incfs/data_mgmt.c b/fs/incfs/data_mgmt.c index 25ea1099946d..109329e0a180 100644 --- a/fs/incfs/data_mgmt.c +++ b/fs/incfs/data_mgmt.c @@ -456,13 +456,9 @@ static struct pending_read *add_pending_read(struct data_file *df, struct data_file_segment *segment = NULL; struct mount_info *mi = NULL; - WARN_ON(!df); segment = get_file_segment(df, block_index); mi = df->df_mount_info; - WARN_ON(!segment); - WARN_ON(!mi); - result = kzalloc(sizeof(*result), GFP_NOFS); if (!result) return NULL; @@ -545,8 +541,6 @@ static int wait_for_data_block(struct data_file *df, int block_index, return -ENODATA; segment = get_file_segment(df, block_index); - WARN_ON(!segment); - error = mutex_lock_interruptible(&segment->blockmap_mutex); if (error) return error; @@ -596,10 +590,10 @@ static int wait_for_data_block(struct data_file *df, int block_index, return -ETIME; } if (wait_res < 0) { - /* - * Only ERESTARTSYS is really expected here when a signal - * comes while we wait. - */ + /* + * Only ERESTARTSYS is really expected here when a signal + * comes while we wait. + */ return wait_res; } diff --git a/fs/incfs/format.c b/fs/incfs/format.c index 27498b9c3d34..247e1b4ec563 100644 --- a/fs/incfs/format.c +++ b/fs/incfs/format.c @@ -12,7 +12,6 @@ #include #include -#include "compat.h" #include "format.h" struct backing_file_context *incfs_alloc_bfc(struct file *backing_file) @@ -679,18 +678,10 @@ int incfs_read_next_metadata_record(struct backing_file_context *bfc, ssize_t incfs_kread(struct file *f, void *buf, size_t size, loff_t pos) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) - return kernel_read(f, pos, (char *)buf, size); -#else return kernel_read(f, buf, size, &pos); -#endif } ssize_t incfs_kwrite(struct file *f, const void *buf, size_t size, loff_t pos) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) - return kernel_write(f, buf, size, pos); -#else return kernel_write(f, buf, size, &pos); -#endif } diff --git a/fs/incfs/integrity.c b/fs/incfs/integrity.c index c6444e73e4d8..feb212c38945 100644 --- a/fs/incfs/integrity.c +++ b/fs/incfs/integrity.c @@ -26,11 +26,7 @@ int incfs_validate_pkcs7_signature(struct mem_range pkcs7_blob, return PTR_ERR(pkcs7); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0) - err = pkcs7_get_content_data(pkcs7, &data, &data_len, false); -#else err = pkcs7_get_content_data(pkcs7, &data, &data_len, NULL); -#endif if (err || data_len == 0 || data == NULL) { pr_debug("PKCS#7 message does not contain data\n"); err = -EBADMSG; diff --git a/fs/incfs/vfs.c b/fs/incfs/vfs.c index 5191ed001e91..c779c60c5c09 100644 --- a/fs/incfs/vfs.c +++ b/fs/incfs/vfs.c @@ -18,7 +18,6 @@ #include -#include "compat.h" #include "data_mgmt.h" #include "format.h" #include "integrity.h" @@ -31,6 +30,9 @@ #define READ_EXEC_FILE_MODE 0555 #define READ_WRITE_FILE_MODE 0666 +/* Needed for kernel 4.14 - remove for later kernels */ +typedef unsigned int __poll_t; + static int incfs_remount_fs(struct super_block *sb, int *flags, char *data); static int dentry_revalidate(struct dentry *dentry, unsigned int flags); @@ -85,16 +87,12 @@ static const struct super_operations incfs_super_ops = { .show_options = show_options }; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) -#define dir_rename_wrap dir_rename -#else static int dir_rename_wrap(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags) { return dir_rename(old_dir, old_dentry, new_dir, new_dentry); } -#endif static const struct inode_operations incfs_dir_inode_ops = { .lookup = dir_lookup, @@ -157,17 +155,6 @@ static const struct file_operations incfs_log_file_ops = { .compat_ioctl = dispatch_ioctl }; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0) - -static const struct inode_operations incfs_file_inode_ops = { - .setattr = simple_setattr, - .getattr = simple_getattr, - .getxattr = incfs_getxattr, - .listxattr = incfs_listxattr -}; - -#else - static const struct inode_operations incfs_file_inode_ops = { .setattr = simple_setattr, .getattr = simple_getattr, @@ -191,9 +178,6 @@ const struct xattr_handler *incfs_xattr_ops[] = { NULL, }; - -#endif - /* State of an open .pending_reads file, unique for each file descriptor. */ struct pending_reads_state { /* A serial number of the last pending read obtained from this file. */ @@ -1645,12 +1629,8 @@ static int dir_unlink(struct inode *dir, struct dentry *dentry) goto out; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) - err = vfs_getattr(&backing_path, &stat); -#else err = vfs_getattr(&backing_path, &stat, STATX_NLINK, AT_STATX_SYNC_AS_STAT); -#endif if (err) goto out; @@ -2076,9 +2056,7 @@ struct dentry *incfs_mount_fs(struct file_system_type *type, int flags, sb->s_time_gran = 1; sb->s_blocksize = INCFS_DATA_FILE_BLOCK_SIZE; sb->s_blocksize_bits = blksize_bits(sb->s_blocksize); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0) sb->s_xattr = incfs_xattr_ops; -#endif BUILD_BUG_ON(PAGE_SIZE != INCFS_DATA_FILE_BLOCK_SIZE);