Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13ef2187 authored by Paul Lawrence's avatar Paul Lawrence
Browse files

ANDROID: Fixing incremental fs style issues



Removed WARN_ONs
Removed compatibilty code
Fixed tab issue

Bug: 133435829
Signed-off-by: default avatarPaul Lawrence <paullawrence@google.com>
Change-Id: I8a9e9ead48a65fd09c2d01d22f65d9a352f118e2
parent d6a968fb
Loading
Loading
Loading
Loading

fs/incfs/compat.h

deleted100644 → 0
+0 −33
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright 2019 Google LLC
 */
#ifndef _INCFS_COMPAT_H
#define _INCFS_COMPAT_H

#include <linux/lz4.h>
#include <linux/version.h>

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 */
+4 −10
Original line number Diff line number Diff line
@@ -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;
+0 −9
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
#include <linux/crc32.h>
#include <linux/kernel.h>

#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
}
+0 −4
Original line number Diff line number Diff line
@@ -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;
+3 −25
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@

#include <uapi/linux/incrementalfs.h>

#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);