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

Commit 6b390e82 authored by Dyneteve's avatar Dyneteve
Browse files

kernel: Update sdfat filesystem

Change-Id: I488101ba5ae319f02836b99534af907b29db8056
parent 559bf6de
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -253,9 +253,15 @@ void sdfat_time_unix2fat(struct sdfat_sb_info *sbi, struct timespec *ts,

TIMESTAMP_T *tm_now(struct sdfat_sb_info *sbi, TIMESTAMP_T *tp)
{
	struct timespec ts = CURRENT_TIME_SEC;
	struct timespec ts;
	DATE_TIME_T dt;

#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
	ts = CURRENT_TIME_SEC;
#else
	ktime_get_real_ts(&ts);
#endif

	sdfat_time_unix2fat(sbi, &ts, &dt);

	tp->year = dt.Year;
@@ -378,4 +384,3 @@ void __sdfat_dmsg(int level, const char *fmt, ...)
#endif
}
#endif
+16 −1
Original line number Diff line number Diff line
@@ -94,7 +94,11 @@ static inline void __sdfat_submit_bio_write2(int flags, struct bio *bio)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
static void  mpage_write_end_io(struct bio *bio)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
	__mpage_write_end_io(bio, bio->bi_status);
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) */
	__mpage_write_end_io(bio, bio->bi_error);
#endif
}
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0) */
static void mpage_write_end_io(struct bio *bio, int err)
@@ -277,7 +281,11 @@ mpage_alloc(struct block_device *bdev,
	}

	if (bio) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)
		bio_set_dev(bio, bdev);
#else
		bio->bi_bdev = bdev;
#endif
		__sdfat_set_bio_sector(bio, first_sector);
	}
	return bio;
@@ -361,7 +369,11 @@ static int sdfat_mpage_writepage(struct page *page,

				if (buffer_new(bh)) {
					clear_buffer_new(bh);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
					clean_bdev_bh_alias(bh);
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) */
					unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr);
#endif
				}
			}

@@ -411,8 +423,12 @@ static int sdfat_mpage_writepage(struct page *page,
			goto confused;

		if (buffer_new(&map_bh))
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
			clean_bdev_bh_alias(&map_bh);
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) */
			unmap_underlying_metadata(map_bh.b_bdev,
					map_bh.b_blocknr);
#endif
		if (buffer_boundary(&map_bh)) {
			boundary_block = map_bh.b_blocknr;
			boundary_bdev = map_bh.b_bdev;
@@ -604,4 +620,3 @@ int sdfat_mpage_writepages(struct address_space *mapping,
}

#endif /* CONFIG_SDFAT_ALIGNED_MPAGE_WRITE */
+45 −39
Original line number Diff line number Diff line
@@ -68,6 +68,9 @@
/* skip iterating emit_dots when dir is empty */
#define ITER_POS_FILLED_DOTS	(2)

#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
#define current_time(x)	(CURRENT_TIME_SEC)
#endif
/* type index declare at sdfat.h */
const char *FS_TYPE_STR[] = {
	"auto",
@@ -219,7 +222,11 @@ static inline void inode_unlock(struct inode *inode)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
static void sdfat_writepage_end_io(struct bio *bio)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
	__sdfat_writepage_end_io(bio, bio->bi_status);
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) */
	__sdfat_writepage_end_io(bio, bio->bi_error);
#endif
}
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) */
static void sdfat_writepage_end_io(struct bio *bio, int err)
@@ -2306,7 +2313,6 @@ static int __sdfat_create(struct inode *dir, struct dentry *dentry)
{
	struct super_block *sb = dir->i_sb;
	struct inode *inode;
	struct timespec ts;
	FILE_ID_T fid;
	loff_t i_pos;
	int err;
@@ -2315,8 +2321,6 @@ static int __sdfat_create(struct inode *dir, struct dentry *dentry)

	TMSG("%s entered\n", __func__);

	ts = CURRENT_TIME_SEC;

	err = fsapi_create(dir, (u8 *) dentry->d_name.name, FM_REGULAR, &fid);
	if (err)
		goto out;
@@ -2324,7 +2328,7 @@ static int __sdfat_create(struct inode *dir, struct dentry *dentry)
	__lock_d_revalidate(dentry);

	dir->i_version++;
	dir->i_ctime = dir->i_mtime = dir->i_atime = ts;
	dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir);
	if (IS_DIRSYNC(dir))
		(void) sdfat_sync_inode(dir);
	else
@@ -2337,7 +2341,7 @@ static int __sdfat_create(struct inode *dir, struct dentry *dentry)
		goto out;
	}
	inode->i_version++;
	inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
	/* timestamp is already written, so mark_inode_dirty() is unneeded. */

	d_instantiate(dentry, inode);
@@ -2471,15 +2475,12 @@ static int sdfat_unlink(struct inode *dir, struct dentry *dentry)
{
	struct inode *inode = dentry->d_inode;
	struct super_block *sb = dir->i_sb;
	struct timespec ts;
	int err;

	__lock_super(sb);

	TMSG("%s entered\n", __func__);

	ts = CURRENT_TIME_SEC;

	SDFAT_I(inode)->fid.size = i_size_read(inode);

	__cancel_dfr_work(inode, 0, SDFAT_I(inode)->fid.size, __func__);
@@ -2491,14 +2492,14 @@ static int sdfat_unlink(struct inode *dir, struct dentry *dentry)
	__lock_d_revalidate(dentry);

	dir->i_version++;
	dir->i_mtime = dir->i_atime = ts;
	dir->i_mtime = dir->i_atime = current_time(dir);
	if (IS_DIRSYNC(dir))
		(void) sdfat_sync_inode(dir);
	else
		mark_inode_dirty(dir);

	clear_nlink(inode);
	inode->i_mtime = inode->i_atime = ts;
	inode->i_mtime = inode->i_atime = current_time(inode);
	sdfat_detach(inode);
	dentry->d_time = dir->i_version;
out:
@@ -2512,7 +2513,6 @@ static int sdfat_symlink(struct inode *dir, struct dentry *dentry, const char *t
{
	struct super_block *sb = dir->i_sb;
	struct inode *inode;
	struct timespec ts;
	FILE_ID_T fid;
	loff_t i_pos;
	int err;
@@ -2527,8 +2527,6 @@ static int sdfat_symlink(struct inode *dir, struct dentry *dentry, const char *t

	TMSG("%s entered\n", __func__);

	ts = CURRENT_TIME_SEC;

	err = fsapi_create(dir, (u8 *) dentry->d_name.name, FM_SYMLINK, &fid);
	if (err)
		goto out;
@@ -2543,7 +2541,7 @@ static int sdfat_symlink(struct inode *dir, struct dentry *dentry, const char *t
	__lock_d_revalidate(dentry);

	dir->i_version++;
	dir->i_ctime = dir->i_mtime = dir->i_atime = ts;
	dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir);
	if (IS_DIRSYNC(dir))
		(void) sdfat_sync_inode(dir);
	else
@@ -2556,7 +2554,7 @@ static int sdfat_symlink(struct inode *dir, struct dentry *dentry, const char *t
		goto out;
	}
	inode->i_version++;
	inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
	/* timestamp is already written, so mark_inode_dirty() is unneeded. */

	SDFAT_I(inode)->target = kmalloc((len+1), GFP_KERNEL);
@@ -2579,7 +2577,6 @@ static int __sdfat_mkdir(struct inode *dir, struct dentry *dentry)
{
	struct super_block *sb = dir->i_sb;
	struct inode *inode;
	struct timespec ts;
	FILE_ID_T fid;
	loff_t i_pos;
	int err;
@@ -2588,8 +2585,6 @@ static int __sdfat_mkdir(struct inode *dir, struct dentry *dentry)

	TMSG("%s entered\n", __func__);

	ts = CURRENT_TIME_SEC;

	err = fsapi_mkdir(dir, (u8 *) dentry->d_name.name, &fid);
	if (err)
		goto out;
@@ -2597,7 +2592,7 @@ static int __sdfat_mkdir(struct inode *dir, struct dentry *dentry)
	__lock_d_revalidate(dentry);

	dir->i_version++;
	dir->i_ctime = dir->i_mtime = dir->i_atime = ts;
	dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir);
	if (IS_DIRSYNC(dir))
		(void) sdfat_sync_inode(dir);
	else
@@ -2611,7 +2606,7 @@ static int __sdfat_mkdir(struct inode *dir, struct dentry *dentry)
		goto out;
	}
	inode->i_version++;
	inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
	/* timestamp is already written, so mark_inode_dirty() is unneeded. */

	d_instantiate(dentry, inode);
@@ -2630,15 +2625,12 @@ static int sdfat_rmdir(struct inode *dir, struct dentry *dentry)
{
	struct inode *inode = dentry->d_inode;
	struct super_block *sb = dir->i_sb;
	struct timespec ts;
	int err;

	__lock_super(sb);

	TMSG("%s entered\n", __func__);

	ts = CURRENT_TIME_SEC;

	SDFAT_I(inode)->fid.size = i_size_read(inode);

	err = fsapi_rmdir(dir, &(SDFAT_I(inode)->fid));
@@ -2648,7 +2640,7 @@ static int sdfat_rmdir(struct inode *dir, struct dentry *dentry)
	__lock_d_revalidate(dentry);

	dir->i_version++;
	dir->i_mtime = dir->i_atime = ts;
	dir->i_mtime = dir->i_atime = current_time(dir);
	if (IS_DIRSYNC(dir))
		(void) sdfat_sync_inode(dir);
	else
@@ -2656,7 +2648,7 @@ static int sdfat_rmdir(struct inode *dir, struct dentry *dentry)
	drop_nlink(dir);

	clear_nlink(inode);
	inode->i_mtime = inode->i_atime = ts;
	inode->i_mtime = inode->i_atime = current_time(inode);
	sdfat_detach(inode);
	dentry->d_time = dir->i_version;
out:
@@ -2671,7 +2663,6 @@ static int __sdfat_rename(struct inode *old_dir, struct dentry *old_dentry,
{
	struct inode *old_inode, *new_inode;
	struct super_block *sb = old_dir->i_sb;
	struct timespec ts;
	loff_t i_pos;
	int err;

@@ -2682,8 +2673,6 @@ static int __sdfat_rename(struct inode *old_dir, struct dentry *old_dentry,
	old_inode = old_dentry->d_inode;
	new_inode = new_dentry->d_inode;

	ts = CURRENT_TIME_SEC;

	SDFAT_I(old_inode)->fid.size = i_size_read(old_inode);

	__cancel_dfr_work(old_inode, 0, 1, __func__);
@@ -2696,7 +2685,7 @@ static int __sdfat_rename(struct inode *old_dir, struct dentry *old_dentry,
	__lock_d_revalidate(new_dentry);

	new_dir->i_version++;
	new_dir->i_ctime = new_dir->i_mtime = new_dir->i_atime = ts;
	new_dir->i_ctime = new_dir->i_mtime = new_dir->i_atime = current_time(new_dir);
	if (IS_DIRSYNC(new_dir))
		(void) sdfat_sync_inode(new_dir);
	else
@@ -2717,7 +2706,7 @@ static int __sdfat_rename(struct inode *old_dir, struct dentry *old_dentry,
	}

	old_dir->i_version++;
	old_dir->i_ctime = old_dir->i_mtime = ts;
	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
	if (IS_DIRSYNC(old_dir))
		(void) sdfat_sync_inode(old_dir);
	else
@@ -2736,7 +2725,7 @@ static int __sdfat_rename(struct inode *old_dir, struct dentry *old_dentry,
				__func__);
			WARN_ON(new_inode->i_nlink == 0);
		}
		new_inode->i_ctime = ts;
		new_inode->i_ctime = current_time(new_inode);
#if 0
		(void) sdfat_sync_inode(new_inode);
#endif
@@ -2760,7 +2749,7 @@ static int sdfat_cont_expand(struct inode *inode, loff_t size)
	if (err)
		return err;

	inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
	inode->i_ctime = inode->i_mtime = current_time(inode);
	mark_inode_dirty(inode);

	if (!IS_SYNC(inode))
@@ -2893,9 +2882,15 @@ static int sdfat_setattr(struct dentry *dentry, struct iattr *attr)
	return error;
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
static int sdfat_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int flags)
{
	struct inode *inode = path->dentry->d_inode;
#else
static int sdfat_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
{
	struct inode *inode = dentry->d_inode;
#endif

	TMSG("%s entered\n", __func__);

@@ -2930,7 +2925,9 @@ static const struct inode_operations sdfat_dir_inode_operations = {
/*  File Operations                                                     */
/*======================================================================*/
static const struct inode_operations sdfat_symlink_inode_operations = {
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
	.readlink    = generic_readlink,
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
	.get_link = sdfat_follow_link,
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) */
@@ -3013,7 +3010,7 @@ static void sdfat_truncate(struct inode *inode, loff_t old_size)
	if (err)
		goto out;

	inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
	inode->i_ctime = inode->i_mtime = current_time(inode);
	if (IS_DIRSYNC(inode))
		(void) sdfat_sync_inode(inode);
	else
@@ -3447,7 +3444,11 @@ static inline void sdfat_submit_fullpage_bio(struct block_device *bdev,
	 */
	bio = bio_alloc(GFP_NOIO, 1);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)
	bio_set_dev(bio, bdev);
#else
	bio->bi_bdev = bdev;
#endif
	bio->bi_vcnt = 1;
	bio->bi_io_vec[0].bv_page = page;	/* Inline vec */
	bio->bi_io_vec[0].bv_len = length;	/* PAGE_SIZE */
@@ -3538,7 +3539,11 @@ static int sdfat_writepage(struct page *page, struct writeback_control *wbc)

			if (buffer_new(bh)) {
				clear_buffer_new(bh);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
				clean_bdev_bh_alias(bh);
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) */
				unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr);
#endif
			}
		}

@@ -3714,7 +3719,7 @@ static int sdfat_write_end(struct file *file, struct address_space *mapping,
		sdfat_write_failed(mapping, pos+len);

	if (!(err < 0) && !(fid->attr & ATTR_ARCHIVE)) {
		inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
		inode->i_mtime = inode->i_ctime = current_time(inode);
		fid->attr |= ATTR_ARCHIVE;
		mark_inode_dirty(inode);
	}
@@ -4720,12 +4725,9 @@ static int sdfat_read_root(struct inode *inode)
{
	struct super_block *sb = inode->i_sb;
	struct sdfat_sb_info *sbi = SDFAT_SB(sb);
	struct timespec ts;
	FS_INFO_T *fsi = &(sbi->fsi);
	DIR_ENTRY_T info;

	ts = CURRENT_TIME_SEC;

	SDFAT_I(inode)->fid.dir.dir = fsi->root_dir;
	SDFAT_I(inode)->fid.dir.flags = 0x01;
	SDFAT_I(inode)->fid.entry = -1;
@@ -4761,7 +4763,7 @@ static int sdfat_read_root(struct inode *inode)
	SDFAT_I(inode)->i_size_ondisk = i_size_read(inode);

	sdfat_save_attr(inode, ATTR_SUBDIR);
	inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
	set_nlink(inode, info.NumSubdirs + 2);
	return 0;
}
@@ -4959,6 +4961,11 @@ static int __init sdfat_init_inodecache(void)

static void sdfat_destroy_inodecache(void)
{
	/*
	 * Make sure all delayed rcu free inodes are flushed before we
	 * destroy cache.
	 */
	rcu_barrier();
	kmem_cache_destroy(sdfat_inode_cachep);
}

@@ -5127,4 +5134,3 @@ module_exit(exit_sdfat_fs);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("FAT/exFAT filesystem support");
MODULE_AUTHOR("Samsung Electronics Co., Ltd.");