mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-22 15:16:33 +00:00
Merge branch 'svn-trunk'
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
@@ -65,8 +65,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
|
||||
|
||||
@@ -329,19 +331,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
|
||||
|
||||
@@ -13320,16 +13320,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;
|
||||
@@ -13403,13 +13393,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;
|
||||
@@ -13501,13 +13485,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;
|
||||
@@ -13522,13 +13500,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;
|
||||
|
||||
@@ -990,13 +990,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;
|
||||
@@ -1008,13 +1002,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;
|
||||
|
||||
@@ -824,10 +824,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
|
||||
|
||||
@@ -542,28 +542,26 @@ sub setScstAttribute {
|
||||
SCST_C_ATTRIBUTE_STATIC);
|
||||
}
|
||||
|
||||
my @_drivers;
|
||||
sub drivers {
|
||||
my $self = shift;
|
||||
my $dHandle = new IO::Handle;
|
||||
my $_path = SCST_TARGETS_DIR();
|
||||
my @drivers;
|
||||
|
||||
if (!@_drivers) {
|
||||
my $dHandle = new IO::Handle;
|
||||
my $_path = SCST_TARGETS_DIR();
|
||||
if (opendir $dHandle, $_path) {
|
||||
foreach my $driver (readdir($dHandle)) {
|
||||
next if (($driver eq '.') || ($driver eq '..'));
|
||||
if (opendir($dHandle, $_path)) {
|
||||
foreach my $driver (readdir($dHandle)) {
|
||||
next if (($driver eq '.') || ($driver eq '..'));
|
||||
|
||||
if (-d make_path(SCST_TARGETS_DIR(), $driver)) {
|
||||
push @_drivers, $driver;
|
||||
}
|
||||
if (-d make_path(SCST_TARGETS_DIR(), $driver)) {
|
||||
push @drivers, $driver;
|
||||
}
|
||||
close $dHandle;
|
||||
} else {
|
||||
return (undef, "drivers(): Unable to read directory '$_path': $!");
|
||||
}
|
||||
close $dHandle;
|
||||
} else {
|
||||
return (undef, "drivers(): Unable to read directory '$_path': $!");
|
||||
}
|
||||
|
||||
return (\@_drivers, undef);
|
||||
return (\@drivers, undef);
|
||||
}
|
||||
|
||||
|
||||
@@ -924,18 +922,14 @@ sub targetGroupTargets {
|
||||
sub driverExists {
|
||||
my $self = shift;
|
||||
my $driver = shift;
|
||||
my $dHandle = new IO::Handle;
|
||||
my $result;
|
||||
|
||||
return FALSE if (!defined($driver));
|
||||
$result = defined($driver) &&
|
||||
opendir($dHandle, make_path(SCST_TARGETS_DIR(), $driver));
|
||||
close $dHandle if ($result);
|
||||
|
||||
my ($drivers, $errorString) = $self->drivers();
|
||||
|
||||
return SCST_C_FATAL_ERROR if (!defined($drivers));
|
||||
|
||||
foreach my $_driver (@{$drivers}) {
|
||||
return TRUE if ($driver eq $_driver);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub driverDynamicAttributes {
|
||||
|
||||
@@ -72,12 +72,14 @@ Set Attribute Operations
|
||||
-attributes <p=v,...>
|
||||
-set_drv_attr <driver> : Sets driver attribute(s) <p> to value <v>.
|
||||
-attributes <p=v,...>
|
||||
-set_dgrp_attr <dgrp> : List all attributes for a given device group.
|
||||
-set_dgrp_attr <dgrp> : Sets device group attribute(s) <p> to value <v>.
|
||||
-attributes <p=v,...>
|
||||
-set_tgrp_attr <tgrp> : List all attributes for a device group/target.
|
||||
-set_tgrp_attr <tgrp> : Sets device group/target attribute(s)
|
||||
<p> to value <v>.
|
||||
-dev_group <dgrp>
|
||||
-attributes <p=v,...>
|
||||
-set_ttgt_attr <tgt> : List all attributes for a target group target.
|
||||
-set_ttgt_attr <tgt> : Set target group target attribute(s)
|
||||
<p> to value <v>.
|
||||
-dev_group <dgrp>
|
||||
-tgt_group <tgrp>
|
||||
-attributes <p=v,...>
|
||||
|
||||
Reference in New Issue
Block a user