scst: Move vfs_fsync() backports to a new header file

This patch does not change any functionality but makes the SCST
source code easier to read. The intention is later on to move all
backported functions and macros from <scst.h> into <backport.h>.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6547 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2015-10-19 17:23:16 +00:00
parent 0acf6c0ec2
commit 16a955ab7b
6 changed files with 58 additions and 58 deletions
+1 -1
View File
@@ -302,7 +302,7 @@ do
done
scst_03_public_headers="scst/include/scst.h scst/include/scst_const.h"
scst_03_public_headers="scst/include/scst.h scst/include/scst_const.h scst/include/backport.h"
scst_04_main="scst/src/scst_main.c scst/src/scst_module.c scst/src/scst_priv.h"
scst_05_targ="scst/src/scst_targ.c"
scst_06_lib="scst/src/scst_lib.c"
+55
View File
@@ -0,0 +1,55 @@
#ifndef _SCST_BACKPORT_H_
#define _SCST_BACKPORT_H_
/*
* Copyright (C) 2015 SanDisk Corporation
*
* Backports of functions introduced in recent kernel versions.
*
* Please keep the functions in this file sorted according to the name of the
* header file in which these have been defined.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2
* of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/writeback.h> /* sync_page_range() */
/* <linux/fs.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) && \
!defined(CONFIG_COMPAT_KERNEL_3_12)
/*
* See also patch "new helper: file_inode(file)" (commit ID
* 496ad9aa8ef448058e36ca7a787c61f2e63f0f54). See also patch
* "kill f_dentry macro" (commit ID 78d28e651f97).
*/
static inline struct inode *file_inode(const struct file *f)
{
return f->f_dentry->d_inode;
}
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
static inline int vfs_fsync_backport(struct file *file, int datasync)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
struct inode *inode = file_inode(file);
return sync_page_range(inode, file->f_mapping, 0, i_size_read(inode));
#else
return vfs_fsync(file, file->f_path.dentry, datasync);
#endif
}
#define vfs_fsync vfs_fsync_backport
#endif
#endif /* _SCST_BACKPORT_H_ */
+2 -13
View File
@@ -64,8 +64,10 @@
#include <scsi/scsi.h>
#ifdef INSIDE_KERNEL_TREE
#include <scst/backport.h>
#include <scst/scst_const.h>
#else
#include <backport.h>
#include <scst_const.h>
#endif
@@ -328,19 +330,6 @@ static inline void hex2bin(u8 *dst, const char *src, size_t count)
}
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) && \
!defined(CONFIG_COMPAT_KERNEL_3_12)
/*
* See also patch "new helper: file_inode(file)" (commit ID
* 496ad9aa8ef448058e36ca7a787c61f2e63f0f54). See also patch
* "kill f_dentry macro" (commit ID 78d28e651f97).
*/
static inline struct inode *file_inode(const struct file *f)
{
return f->f_dentry->d_inode;
}
#endif
#ifndef __list_for_each
/* ToDo: cleanup when both are the same for all relevant kernels */
#define __list_for_each list_for_each
-28
View File
@@ -13147,16 +13147,6 @@ void scst_path_put(struct nameidata *nd)
EXPORT_SYMBOL(scst_path_put);
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
int scst_vfs_fsync(struct file *file, loff_t loff, loff_t len)
{
int res;
res = sync_page_range(file_inode(file), file->f_mapping, loff, len);
return res;
}
#endif
int scst_copy_file(const char *src, const char *dest)
{
int res = 0;
@@ -13230,13 +13220,7 @@ int scst_copy_file(const char *src, const char *dest)
goto out_skip;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
res = scst_vfs_fsync(file_dest, 0, file_size);
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
res = vfs_fsync(file_dest, file_dest->f_path.dentry, 0);
#else
res = vfs_fsync(file_dest, 0);
#endif
if (res != 0) {
PRINT_ERROR("fsync() of the backup PR file failed: %d", res);
goto out_skip;
@@ -13328,13 +13312,7 @@ int scst_write_file_transactional(const char *name, const char *name1,
if (res != size)
goto write_error;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
res = scst_vfs_fsync(file, 0, pos);
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
res = vfs_fsync(file, file->f_path.dentry, 1);
#else
res = vfs_fsync(file, 1);
#endif
if (res != 0) {
PRINT_ERROR("fsync() of file %s failed: %d", name, res);
goto write_error_close;
@@ -13349,13 +13327,7 @@ int scst_write_file_transactional(const char *name, const char *name1,
if (res != sizeof(n))
goto write_error;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
res = scst_vfs_fsync(file, 0, sizeof(signature));
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
res = vfs_fsync(file, file->f_path.dentry, 1);
#else
res = vfs_fsync(file, 1);
#endif
if (res != 0) {
PRINT_ERROR("fsync() of file %s failed: %d", name, res);
goto write_error_close;
-12
View File
@@ -986,13 +986,7 @@ void scst_pr_sync_device_file(struct scst_tgt_dev *tgt_dev, struct scst_cmd *cmd
goto write_error;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
res = scst_vfs_fsync(file, 0, pos);
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
res = vfs_fsync(file, file->f_path.dentry, 1);
#else
res = vfs_fsync(file, 1);
#endif
if (res != 0) {
PRINT_ERROR("fsync() of the PR file failed: %d", res);
goto write_error_close;
@@ -1004,13 +998,7 @@ void scst_pr_sync_device_file(struct scst_tgt_dev *tgt_dev, struct scst_cmd *cmd
if (res != sizeof(sign))
goto write_error;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
res = scst_vfs_fsync(file, 0, sizeof(sign));
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
res = vfs_fsync(file, file->f_path.dentry, 1);
#else
res = vfs_fsync(file, 1);
#endif
if (res != 0) {
PRINT_ERROR("fsync() of the PR file failed: %d", res);
goto write_error_close;
-4
View File
@@ -781,10 +781,6 @@ void scst_vfs_unlink_and_put(struct nameidata *nd);
void scst_vfs_unlink_and_put(struct path *path);
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
int scst_vfs_fsync(struct file *file, loff_t loff, loff_t len);
#endif
int scst_copy_file(const char *src, const char *dest);
#ifdef CONFIG_SCST_DEBUG_TM