- Use vfs_readv/vfs_writev instead of direct calls to VFS functions

- Cleanups



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1243 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2009-10-22 15:19:11 +00:00
parent 173e97d2bd
commit 6606bb50de
5 changed files with 11 additions and 81 deletions

View File

@@ -41,10 +41,6 @@
#include <scst_const.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
#define kobj_attribute device_attribute
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
#ifndef RHEL_RELEASE_CODE
typedef _Bool bool;

View File

@@ -678,21 +678,6 @@ static int vdisk_get_file_size(const char *file_name, bool blockio,
goto out;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
if ((fd->f_op == NULL) ||
(fd->f_op->readv == NULL) ||
(fd->f_op->writev == NULL)) {
#else
if ((fd->f_op == NULL) ||
(fd->f_op->aio_read == NULL) ||
(fd->f_op->aio_write == NULL)) {
#endif
PRINT_ERROR("%s", "Wrong f_op or FS doesn't have required "
"capabilities");
res = -EINVAL;
goto out_close;
}
inode = fd->f_dentry->d_inode;
if (blockio && !S_ISBLK(inode->i_mode)) {
@@ -2352,48 +2337,6 @@ out:
return thr->iv;
}
/*
* copied from <ksrc>/fs/read_write.*
*/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
static void wait_on_retry_sync_kiocb(struct kiocb *iocb)
{
set_current_state(TASK_UNINTERRUPTIBLE);
if (!kiocbIsKicked(iocb))
schedule();
else
kiocbClearKicked(iocb);
__set_current_state(TASK_RUNNING);
}
typedef ssize_t (*iov_fn_t)(struct kiocb *, const struct iovec *,
unsigned long, loff_t);
static ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov,
unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn)
{
struct kiocb kiocb;
ssize_t ret;
init_sync_kiocb(&kiocb, filp);
kiocb.ki_pos = *ppos;
kiocb.ki_left = len;
kiocb.ki_nbytes = len;
for (;;) {
ret = fn(&kiocb, iov, nr_segs, kiocb.ki_pos);
if (ret != -EIOCBRETRY)
break;
wait_on_retry_sync_kiocb(&kiocb);
}
if (ret == -EIOCBQUEUED)
ret = wait_on_sync_kiocb(&kiocb);
*ppos = kiocb.ki_pos;
return ret;
}
#endif
static void vdisk_exec_read(struct scst_cmd *cmd,
struct scst_vdisk_thr *thr, loff_t loff)
{
@@ -2454,12 +2397,7 @@ static void vdisk_exec_read(struct scst_cmd *cmd,
}
/* READ */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
err = fd->f_op->readv(fd, iv, iv_count, &fd->f_pos);
#else
err = do_sync_readv_writev(fd, iv, iv_count, full_len,
&fd->f_pos, fd->f_op->aio_read);
#endif
err = vfs_readv(fd, iv, iv_count, &fd->f_pos);
if ((err < 0) || (err < full_len)) {
PRINT_ERROR("readv() returned %lld from %zd",
@@ -2548,12 +2486,7 @@ restart:
}
/* WRITE */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
err = fd->f_op->writev(fd, eiv, eiv_count, &fd->f_pos);
#else
err = do_sync_readv_writev(fd, iv, iv_count, full_len, &fd->f_pos,
fd->f_op->aio_write);
#endif
err = vfs_writev(fd, eiv, eiv_count, &fd->f_pos);
if (err < 0) {
PRINT_ERROR("write() returned %lld from %zd",
@@ -2868,9 +2801,8 @@ static void vdisk_exec_verify(struct scst_cmd *cmd,
TRACE_DBG("Verify: length %zd - len_mem %zd", length, len_mem);
if (!virt_dev->nullio)
err = fd->f_op->read(fd,
(char __force __user *)mem_verify, len_mem,
&fd->f_pos);
err = vfs_read(fd, (char __force __user *)mem_verify,
len_mem, &fd->f_pos);
else
err = len_mem;
if ((err < 0) || (err < len_mem)) {

View File

@@ -218,6 +218,7 @@ int __scst_register_target_template(struct scst_tgt_template *vtt,
goto out_err;
}
#ifndef CONFIG_SCST_PROC
if (!vtt->enable_tgt || !vtt->is_tgt_enabled) {
PRINT_WARNING("Target driver %s doesn't have enable_tgt() "
"and/or is_tgt_enabled() method(s). This is unsafe "
@@ -225,8 +226,7 @@ int __scst_register_target_template(struct scst_tgt_template *vtt,
"initialization time can see an unexpected set of "
"devices or no devices at all!", vtt->name);
}
#ifdef CONFIG_SCST_PROC
#else
if (!vtt->no_proc_entry) {
res = scst_build_proc_target_dir_entries(vtt);
if (res < 0)

View File

@@ -1742,7 +1742,7 @@ int sgv_procinfo_show(struct seq_file *seq, void *v)
return 0;
}
#endif /* CONFIG_SCST_PROC */
#else /* CONFIG_SCST_PROC */
ssize_t sgv_sysfs_stat_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
@@ -1828,3 +1828,5 @@ ssize_t sgv_sysfs_global_stat_show(struct kobject *kobj,
TRACE_EXIT();
return res;
}
#endif /* CONFIG_SCST_PROC */

View File

@@ -130,12 +130,12 @@ void sgv_pool_destroy(struct sgv_pool *pool);
#ifdef CONFIG_SCST_PROC
int sgv_procinfo_show(struct seq_file *seq, void *v);
#endif
#else
ssize_t sgv_sysfs_stat_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf);
ssize_t sgv_sysfs_global_stat_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf);
#endif
void scst_sgv_pool_use_norm(struct scst_tgt_dev *tgt_dev);
void scst_sgv_pool_use_norm_clust(struct scst_tgt_dev *tgt_dev);