Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Filename: target_core_file.c |
| 3 | * |
| 4 | * This file contains the Storage Engine <-> FILEIO transport specific functions |
| 5 | * |
| 6 | * Copyright (c) 2005 PyX Technologies, Inc. |
| 7 | * Copyright (c) 2005-2006 SBE, Inc. All Rights Reserved. |
| 8 | * Copyright (c) 2007-2010 Rising Tide Systems |
| 9 | * Copyright (c) 2008-2010 Linux-iSCSI.org |
| 10 | * |
| 11 | * Nicholas A. Bellinger <nab@kernel.org> |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2 of the License, or |
| 16 | * (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program; if not, write to the Free Software |
| 25 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 26 | * |
| 27 | ******************************************************************************/ |
| 28 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 29 | #include <linux/string.h> |
| 30 | #include <linux/parser.h> |
| 31 | #include <linux/timer.h> |
| 32 | #include <linux/blkdev.h> |
| 33 | #include <linux/slab.h> |
| 34 | #include <linux/spinlock.h> |
Paul Gortmaker | 827509e | 2011-08-30 14:20:44 -0400 | [diff] [blame] | 35 | #include <linux/module.h> |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 36 | #include <scsi/scsi.h> |
| 37 | #include <scsi/scsi_host.h> |
| 38 | |
| 39 | #include <target/target_core_base.h> |
Christoph Hellwig | c4795fb | 2011-11-16 09:46:48 -0500 | [diff] [blame] | 40 | #include <target/target_core_backend.h> |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 41 | |
| 42 | #include "target_core_file.h" |
| 43 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 44 | static inline struct fd_dev *FD_DEV(struct se_device *dev) |
| 45 | { |
| 46 | return container_of(dev, struct fd_dev, dev); |
| 47 | } |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 48 | |
| 49 | /* fd_attach_hba(): (Part of se_subsystem_api_t template) |
| 50 | * |
| 51 | * |
| 52 | */ |
| 53 | static int fd_attach_hba(struct se_hba *hba, u32 host_id) |
| 54 | { |
| 55 | struct fd_host *fd_host; |
| 56 | |
| 57 | fd_host = kzalloc(sizeof(struct fd_host), GFP_KERNEL); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 58 | if (!fd_host) { |
| 59 | pr_err("Unable to allocate memory for struct fd_host\n"); |
Andy Grover | e3d6f90 | 2011-07-19 08:55:10 +0000 | [diff] [blame] | 60 | return -ENOMEM; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | fd_host->fd_host_id = host_id; |
| 64 | |
Andy Grover | e3d6f90 | 2011-07-19 08:55:10 +0000 | [diff] [blame] | 65 | hba->hba_ptr = fd_host; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 66 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 67 | pr_debug("CORE_HBA[%d] - TCM FILEIO HBA Driver %s on Generic" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 68 | " Target Core Stack %s\n", hba->hba_id, FD_VERSION, |
| 69 | TARGET_CORE_MOD_VERSION); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 70 | pr_debug("CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic" |
Andy Grover | e3d6f90 | 2011-07-19 08:55:10 +0000 | [diff] [blame] | 71 | " MaxSectors: %u\n", |
| 72 | hba->hba_id, fd_host->fd_host_id, FD_MAX_SECTORS); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | static void fd_detach_hba(struct se_hba *hba) |
| 78 | { |
| 79 | struct fd_host *fd_host = hba->hba_ptr; |
| 80 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 81 | pr_debug("CORE_HBA[%d] - Detached FILEIO HBA: %u from Generic" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 82 | " Target Core\n", hba->hba_id, fd_host->fd_host_id); |
| 83 | |
| 84 | kfree(fd_host); |
| 85 | hba->hba_ptr = NULL; |
| 86 | } |
| 87 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 88 | static struct se_device *fd_alloc_device(struct se_hba *hba, const char *name) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 89 | { |
| 90 | struct fd_dev *fd_dev; |
Jörn Engel | 8359cf4 | 2011-11-24 02:05:51 +0100 | [diff] [blame] | 91 | struct fd_host *fd_host = hba->hba_ptr; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 92 | |
| 93 | fd_dev = kzalloc(sizeof(struct fd_dev), GFP_KERNEL); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 94 | if (!fd_dev) { |
| 95 | pr_err("Unable to allocate memory for struct fd_dev\n"); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 96 | return NULL; |
| 97 | } |
| 98 | |
| 99 | fd_dev->fd_host = fd_host; |
| 100 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 101 | pr_debug("FILEIO: Allocated fd_dev for %p\n", name); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 102 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 103 | return &fd_dev->dev; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 104 | } |
| 105 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 106 | static int fd_configure_device(struct se_device *dev) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 107 | { |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 108 | struct fd_dev *fd_dev = FD_DEV(dev); |
| 109 | struct fd_host *fd_host = dev->se_hba->hba_ptr; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 110 | struct file *file; |
| 111 | struct inode *inode = NULL; |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 112 | int flags, ret = -EINVAL; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 113 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 114 | if (!(fd_dev->fbd_flags & FBDF_HAS_PATH)) { |
| 115 | pr_err("Missing fd_dev_name=\n"); |
| 116 | return -EINVAL; |
| 117 | } |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 118 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 119 | /* |
Nicholas Bellinger | a4dff30 | 2012-05-30 16:25:41 -0700 | [diff] [blame] | 120 | * Use O_DSYNC by default instead of O_SYNC to forgo syncing |
| 121 | * of pure timestamp updates. |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 122 | */ |
Nicholas Bellinger | a4dff30 | 2012-05-30 16:25:41 -0700 | [diff] [blame] | 123 | flags = O_RDWR | O_CREAT | O_LARGEFILE | O_DSYNC; |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 124 | |
Nicholas Bellinger | b32f4c7 | 2012-09-29 17:15:37 -0700 | [diff] [blame] | 125 | /* |
| 126 | * Optionally allow fd_buffered_io=1 to be enabled for people |
| 127 | * who want use the fs buffer cache as an WriteCache mechanism. |
| 128 | * |
| 129 | * This means that in event of a hard failure, there is a risk |
| 130 | * of silent data-loss if the SCSI client has *not* performed a |
| 131 | * forced unit access (FUA) write, or issued SYNCHRONIZE_CACHE |
| 132 | * to write-out the entire device cache. |
| 133 | */ |
| 134 | if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) { |
| 135 | pr_debug("FILEIO: Disabling O_DSYNC, using buffered FILEIO\n"); |
| 136 | flags &= ~O_DSYNC; |
| 137 | } |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 138 | |
Al Viro | dbc6e02 | 2012-08-01 13:07:04 +0400 | [diff] [blame] | 139 | file = filp_open(fd_dev->fd_dev_name, flags, 0600); |
Nicholas Bellinger | 613640e | 2011-03-14 04:05:59 -0700 | [diff] [blame] | 140 | if (IS_ERR(file)) { |
Al Viro | dbc6e02 | 2012-08-01 13:07:04 +0400 | [diff] [blame] | 141 | pr_err("filp_open(%s) failed\n", fd_dev->fd_dev_name); |
Nicholas Bellinger | 613640e | 2011-03-14 04:05:59 -0700 | [diff] [blame] | 142 | ret = PTR_ERR(file); |
| 143 | goto fail; |
| 144 | } |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 145 | fd_dev->fd_file = file; |
| 146 | /* |
| 147 | * If using a block backend with this struct file, we extract |
| 148 | * fd_dev->fd_[block,dev]_size from struct block_device. |
| 149 | * |
| 150 | * Otherwise, we use the passed fd_size= from configfs |
| 151 | */ |
| 152 | inode = file->f_mapping->host; |
| 153 | if (S_ISBLK(inode->i_mode)) { |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 154 | struct request_queue *q = bdev_get_queue(inode->i_bdev); |
Nicholas Bellinger | cd9323f | 2012-05-16 16:05:26 -0700 | [diff] [blame] | 155 | unsigned long long dev_size; |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 156 | |
| 157 | dev->dev_attrib.hw_block_size = |
| 158 | bdev_logical_block_size(inode->i_bdev); |
| 159 | dev->dev_attrib.hw_max_sectors = queue_max_hw_sectors(q); |
| 160 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 161 | /* |
| 162 | * Determine the number of bytes from i_size_read() minus |
| 163 | * one (1) logical sector from underlying struct block_device |
| 164 | */ |
Nicholas Bellinger | cd9323f | 2012-05-16 16:05:26 -0700 | [diff] [blame] | 165 | dev_size = (i_size_read(file->f_mapping->host) - |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 166 | fd_dev->fd_block_size); |
| 167 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 168 | pr_debug("FILEIO: Using size: %llu bytes from struct" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 169 | " block_device blocks: %llu logical_block_size: %d\n", |
Nicholas Bellinger | cd9323f | 2012-05-16 16:05:26 -0700 | [diff] [blame] | 170 | dev_size, div_u64(dev_size, fd_dev->fd_block_size), |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 171 | fd_dev->fd_block_size); |
| 172 | } else { |
| 173 | if (!(fd_dev->fbd_flags & FBDF_HAS_SIZE)) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 174 | pr_err("FILEIO: Missing fd_dev_size=" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 175 | " parameter, and no backing struct" |
| 176 | " block_device\n"); |
| 177 | goto fail; |
| 178 | } |
| 179 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 180 | dev->dev_attrib.hw_block_size = FD_BLOCKSIZE; |
| 181 | dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 182 | } |
| 183 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 184 | fd_dev->fd_block_size = dev->dev_attrib.hw_block_size; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 185 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 186 | dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 187 | |
Nicholas Bellinger | b32f4c7 | 2012-09-29 17:15:37 -0700 | [diff] [blame] | 188 | if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) { |
| 189 | pr_debug("FILEIO: Forcing setting of emulate_write_cache=1" |
| 190 | " with FDBD_HAS_BUFFERED_IO_WCE\n"); |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 191 | dev->dev_attrib.emulate_write_cache = 1; |
Nicholas Bellinger | b32f4c7 | 2012-09-29 17:15:37 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 194 | fd_dev->fd_dev_id = fd_host->fd_host_dev_id_count++; |
| 195 | fd_dev->fd_queue_depth = dev->queue_depth; |
| 196 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 197 | pr_debug("CORE_FILE[%u] - Added TCM FILEIO Device ID: %u at %s," |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 198 | " %llu total bytes\n", fd_host->fd_host_id, fd_dev->fd_dev_id, |
| 199 | fd_dev->fd_dev_name, fd_dev->fd_dev_size); |
| 200 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 201 | return 0; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 202 | fail: |
| 203 | if (fd_dev->fd_file) { |
| 204 | filp_close(fd_dev->fd_file, NULL); |
| 205 | fd_dev->fd_file = NULL; |
| 206 | } |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 207 | return ret; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 208 | } |
| 209 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 210 | static void fd_free_device(struct se_device *dev) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 211 | { |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 212 | struct fd_dev *fd_dev = FD_DEV(dev); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 213 | |
| 214 | if (fd_dev->fd_file) { |
| 215 | filp_close(fd_dev->fd_file, NULL); |
| 216 | fd_dev->fd_file = NULL; |
| 217 | } |
| 218 | |
| 219 | kfree(fd_dev); |
| 220 | } |
| 221 | |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 222 | static int fd_do_readv(struct se_cmd *cmd, struct scatterlist *sgl, |
| 223 | u32 sgl_nents) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 224 | { |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 225 | struct se_device *se_dev = cmd->se_dev; |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 226 | struct fd_dev *dev = FD_DEV(se_dev); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 227 | struct file *fd = dev->fd_file; |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 228 | struct scatterlist *sg; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 229 | struct iovec *iov; |
| 230 | mm_segment_t old_fs; |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 231 | loff_t pos = (cmd->t_task_lba * se_dev->dev_attrib.block_size); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 232 | int ret = 0, i; |
| 233 | |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 234 | iov = kzalloc(sizeof(struct iovec) * sgl_nents, GFP_KERNEL); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 235 | if (!iov) { |
| 236 | pr_err("Unable to allocate fd_do_readv iov[]\n"); |
Andy Grover | e3d6f90 | 2011-07-19 08:55:10 +0000 | [diff] [blame] | 237 | return -ENOMEM; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 238 | } |
| 239 | |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 240 | for_each_sg(sgl, sg, sgl_nents, i) { |
Sebastian Andrzej Siewior | 9649fa1 | 2011-11-28 12:33:10 +0100 | [diff] [blame] | 241 | iov[i].iov_len = sg->length; |
| 242 | iov[i].iov_base = sg_virt(sg); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | old_fs = get_fs(); |
| 246 | set_fs(get_ds()); |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 247 | ret = vfs_readv(fd, &iov[0], sgl_nents, &pos); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 248 | set_fs(old_fs); |
| 249 | |
| 250 | kfree(iov); |
| 251 | /* |
| 252 | * Return zeros and GOOD status even if the READ did not return |
| 253 | * the expected virt_size for struct file w/o a backing struct |
| 254 | * block_device. |
| 255 | */ |
| 256 | if (S_ISBLK(fd->f_dentry->d_inode->i_mode)) { |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 257 | if (ret < 0 || ret != cmd->data_length) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 258 | pr_err("vfs_readv() returned %d," |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 259 | " expecting %d for S_ISBLK\n", ret, |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 260 | (int)cmd->data_length); |
Andy Grover | e3d6f90 | 2011-07-19 08:55:10 +0000 | [diff] [blame] | 261 | return (ret < 0 ? ret : -EINVAL); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 262 | } |
| 263 | } else { |
| 264 | if (ret < 0) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 265 | pr_err("vfs_readv() returned %d for non" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 266 | " S_ISBLK\n", ret); |
Andy Grover | e3d6f90 | 2011-07-19 08:55:10 +0000 | [diff] [blame] | 267 | return ret; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
| 271 | return 1; |
| 272 | } |
| 273 | |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 274 | static int fd_do_writev(struct se_cmd *cmd, struct scatterlist *sgl, |
| 275 | u32 sgl_nents) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 276 | { |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 277 | struct se_device *se_dev = cmd->se_dev; |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 278 | struct fd_dev *dev = FD_DEV(se_dev); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 279 | struct file *fd = dev->fd_file; |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 280 | struct scatterlist *sg; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 281 | struct iovec *iov; |
| 282 | mm_segment_t old_fs; |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 283 | loff_t pos = (cmd->t_task_lba * se_dev->dev_attrib.block_size); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 284 | int ret, i = 0; |
| 285 | |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 286 | iov = kzalloc(sizeof(struct iovec) * sgl_nents, GFP_KERNEL); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 287 | if (!iov) { |
| 288 | pr_err("Unable to allocate fd_do_writev iov[]\n"); |
Andy Grover | e3d6f90 | 2011-07-19 08:55:10 +0000 | [diff] [blame] | 289 | return -ENOMEM; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 290 | } |
| 291 | |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 292 | for_each_sg(sgl, sg, sgl_nents, i) { |
Sebastian Andrzej Siewior | 9649fa1 | 2011-11-28 12:33:10 +0100 | [diff] [blame] | 293 | iov[i].iov_len = sg->length; |
| 294 | iov[i].iov_base = sg_virt(sg); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | old_fs = get_fs(); |
| 298 | set_fs(get_ds()); |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 299 | ret = vfs_writev(fd, &iov[0], sgl_nents, &pos); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 300 | set_fs(old_fs); |
| 301 | |
| 302 | kfree(iov); |
| 303 | |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 304 | if (ret < 0 || ret != cmd->data_length) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 305 | pr_err("vfs_writev() returned %d\n", ret); |
Andy Grover | e3d6f90 | 2011-07-19 08:55:10 +0000 | [diff] [blame] | 306 | return (ret < 0 ? ret : -EINVAL); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | return 1; |
| 310 | } |
| 311 | |
Christoph Hellwig | de103c9 | 2012-11-06 12:24:09 -0800 | [diff] [blame^] | 312 | static sense_reason_t |
| 313 | fd_execute_sync_cache(struct se_cmd *cmd) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 314 | { |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 315 | struct se_device *dev = cmd->se_dev; |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 316 | struct fd_dev *fd_dev = FD_DEV(dev); |
Andy Grover | a1d8b49 | 2011-05-02 17:12:10 -0700 | [diff] [blame] | 317 | int immed = (cmd->t_task_cdb[1] & 0x2); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 318 | loff_t start, end; |
| 319 | int ret; |
| 320 | |
| 321 | /* |
| 322 | * If the Immediate bit is set, queue up the GOOD response |
| 323 | * for this SYNCHRONIZE_CACHE op |
| 324 | */ |
| 325 | if (immed) |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 326 | target_complete_cmd(cmd, SAM_STAT_GOOD); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 327 | |
| 328 | /* |
| 329 | * Determine if we will be flushing the entire device. |
| 330 | */ |
Andy Grover | a1d8b49 | 2011-05-02 17:12:10 -0700 | [diff] [blame] | 331 | if (cmd->t_task_lba == 0 && cmd->data_length == 0) { |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 332 | start = 0; |
| 333 | end = LLONG_MAX; |
| 334 | } else { |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 335 | start = cmd->t_task_lba * dev->dev_attrib.block_size; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 336 | if (cmd->data_length) |
| 337 | end = start + cmd->data_length; |
| 338 | else |
| 339 | end = LLONG_MAX; |
| 340 | } |
| 341 | |
| 342 | ret = vfs_fsync_range(fd_dev->fd_file, start, end, 1); |
| 343 | if (ret != 0) |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 344 | pr_err("FILEIO: vfs_fsync_range() failed: %d\n", ret); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 345 | |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 346 | if (immed) |
Christoph Hellwig | ad67f0d | 2012-06-17 18:40:53 -0400 | [diff] [blame] | 347 | return 0; |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 348 | |
Christoph Hellwig | de103c9 | 2012-11-06 12:24:09 -0800 | [diff] [blame^] | 349 | if (ret) |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 350 | target_complete_cmd(cmd, SAM_STAT_CHECK_CONDITION); |
Christoph Hellwig | de103c9 | 2012-11-06 12:24:09 -0800 | [diff] [blame^] | 351 | else |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 352 | target_complete_cmd(cmd, SAM_STAT_GOOD); |
Christoph Hellwig | ad67f0d | 2012-06-17 18:40:53 -0400 | [diff] [blame] | 353 | |
| 354 | return 0; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 355 | } |
| 356 | |
Christoph Hellwig | de103c9 | 2012-11-06 12:24:09 -0800 | [diff] [blame^] | 357 | static sense_reason_t |
| 358 | fd_execute_rw(struct se_cmd *cmd) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 359 | { |
Christoph Hellwig | 0c2ad7d | 2012-06-17 18:40:52 -0400 | [diff] [blame] | 360 | struct scatterlist *sgl = cmd->t_data_sg; |
| 361 | u32 sgl_nents = cmd->t_data_nents; |
| 362 | enum dma_data_direction data_direction = cmd->data_direction; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 363 | struct se_device *dev = cmd->se_dev; |
| 364 | int ret = 0; |
| 365 | |
| 366 | /* |
| 367 | * Call vectorized fileio functions to map struct scatterlist |
| 368 | * physical memory addresses to struct iovec virtual memory. |
| 369 | */ |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 370 | if (data_direction == DMA_FROM_DEVICE) { |
| 371 | ret = fd_do_readv(cmd, sgl, sgl_nents); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 372 | } else { |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 373 | ret = fd_do_writev(cmd, sgl, sgl_nents); |
Nicholas Bellinger | a4dff30 | 2012-05-30 16:25:41 -0700 | [diff] [blame] | 374 | /* |
| 375 | * Perform implict vfs_fsync_range() for fd_do_writev() ops |
| 376 | * for SCSI WRITEs with Forced Unit Access (FUA) set. |
| 377 | * Allow this to happen independent of WCE=0 setting. |
| 378 | */ |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 379 | if (ret > 0 && |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 380 | dev->dev_attrib.emulate_fua_write > 0 && |
Christoph Hellwig | 2d3a4b5 | 2011-11-14 11:36:29 -0500 | [diff] [blame] | 381 | (cmd->se_cmd_flags & SCF_FUA)) { |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 382 | struct fd_dev *fd_dev = FD_DEV(dev); |
Nicholas Bellinger | a4dff30 | 2012-05-30 16:25:41 -0700 | [diff] [blame] | 383 | loff_t start = cmd->t_task_lba * |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 384 | dev->dev_attrib.block_size; |
Nicholas Bellinger | a4dff30 | 2012-05-30 16:25:41 -0700 | [diff] [blame] | 385 | loff_t end = start + cmd->data_length; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 386 | |
Nicholas Bellinger | a4dff30 | 2012-05-30 16:25:41 -0700 | [diff] [blame] | 387 | vfs_fsync_range(fd_dev->fd_file, start, end, 1); |
| 388 | } |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 389 | } |
| 390 | |
Christoph Hellwig | de103c9 | 2012-11-06 12:24:09 -0800 | [diff] [blame^] | 391 | if (ret < 0) |
| 392 | return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
| 393 | |
Christoph Hellwig | 5787cac | 2012-04-24 00:25:06 -0400 | [diff] [blame] | 394 | if (ret) |
| 395 | target_complete_cmd(cmd, SAM_STAT_GOOD); |
Nicholas Bellinger | 03e98c9 | 2011-11-04 02:36:16 -0700 | [diff] [blame] | 396 | return 0; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 397 | } |
| 398 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 399 | enum { |
| 400 | Opt_fd_dev_name, Opt_fd_dev_size, Opt_fd_buffered_io, Opt_err |
| 401 | }; |
| 402 | |
| 403 | static match_table_t tokens = { |
| 404 | {Opt_fd_dev_name, "fd_dev_name=%s"}, |
| 405 | {Opt_fd_dev_size, "fd_dev_size=%s"}, |
Nicholas Bellinger | b32f4c7 | 2012-09-29 17:15:37 -0700 | [diff] [blame] | 406 | {Opt_fd_buffered_io, "fd_buffered_io=%d"}, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 407 | {Opt_err, NULL} |
| 408 | }; |
| 409 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 410 | static ssize_t fd_set_configfs_dev_params(struct se_device *dev, |
| 411 | const char *page, ssize_t count) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 412 | { |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 413 | struct fd_dev *fd_dev = FD_DEV(dev); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 414 | char *orig, *ptr, *arg_p, *opts; |
| 415 | substring_t args[MAX_OPT_ARGS]; |
Nicholas Bellinger | b32f4c7 | 2012-09-29 17:15:37 -0700 | [diff] [blame] | 416 | int ret = 0, arg, token; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 417 | |
| 418 | opts = kstrdup(page, GFP_KERNEL); |
| 419 | if (!opts) |
| 420 | return -ENOMEM; |
| 421 | |
| 422 | orig = opts; |
| 423 | |
Sebastian Andrzej Siewior | 90c161b | 2011-11-23 20:53:17 +0100 | [diff] [blame] | 424 | while ((ptr = strsep(&opts, ",\n")) != NULL) { |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 425 | if (!*ptr) |
| 426 | continue; |
| 427 | |
| 428 | token = match_token(ptr, tokens, args); |
| 429 | switch (token) { |
| 430 | case Opt_fd_dev_name: |
Al Viro | dbc6e02 | 2012-08-01 13:07:04 +0400 | [diff] [blame] | 431 | if (match_strlcpy(fd_dev->fd_dev_name, &args[0], |
| 432 | FD_MAX_DEV_NAME) == 0) { |
| 433 | ret = -EINVAL; |
Jesper Juhl | 6d18025 | 2011-03-14 04:05:56 -0700 | [diff] [blame] | 434 | break; |
| 435 | } |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 436 | pr_debug("FILEIO: Referencing Path: %s\n", |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 437 | fd_dev->fd_dev_name); |
| 438 | fd_dev->fbd_flags |= FBDF_HAS_PATH; |
| 439 | break; |
| 440 | case Opt_fd_dev_size: |
| 441 | arg_p = match_strdup(&args[0]); |
Jesper Juhl | 6d18025 | 2011-03-14 04:05:56 -0700 | [diff] [blame] | 442 | if (!arg_p) { |
| 443 | ret = -ENOMEM; |
| 444 | break; |
| 445 | } |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 446 | ret = strict_strtoull(arg_p, 0, &fd_dev->fd_dev_size); |
Jesper Juhl | 6d18025 | 2011-03-14 04:05:56 -0700 | [diff] [blame] | 447 | kfree(arg_p); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 448 | if (ret < 0) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 449 | pr_err("strict_strtoull() failed for" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 450 | " fd_dev_size=\n"); |
| 451 | goto out; |
| 452 | } |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 453 | pr_debug("FILEIO: Referencing Size: %llu" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 454 | " bytes\n", fd_dev->fd_dev_size); |
| 455 | fd_dev->fbd_flags |= FBDF_HAS_SIZE; |
| 456 | break; |
Nicholas Bellinger | b32f4c7 | 2012-09-29 17:15:37 -0700 | [diff] [blame] | 457 | case Opt_fd_buffered_io: |
| 458 | match_int(args, &arg); |
| 459 | if (arg != 1) { |
| 460 | pr_err("bogus fd_buffered_io=%d value\n", arg); |
| 461 | ret = -EINVAL; |
| 462 | goto out; |
| 463 | } |
| 464 | |
| 465 | pr_debug("FILEIO: Using buffered I/O" |
| 466 | " operations for struct fd_dev\n"); |
| 467 | |
| 468 | fd_dev->fbd_flags |= FDBD_HAS_BUFFERED_IO_WCE; |
| 469 | break; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 470 | default: |
| 471 | break; |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | out: |
| 476 | kfree(orig); |
| 477 | return (!ret) ? count : ret; |
| 478 | } |
| 479 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 480 | static ssize_t fd_show_configfs_dev_params(struct se_device *dev, char *b) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 481 | { |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 482 | struct fd_dev *fd_dev = FD_DEV(dev); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 483 | ssize_t bl = 0; |
| 484 | |
| 485 | bl = sprintf(b + bl, "TCM FILEIO ID: %u", fd_dev->fd_dev_id); |
Nicholas Bellinger | b32f4c7 | 2012-09-29 17:15:37 -0700 | [diff] [blame] | 486 | bl += sprintf(b + bl, " File: %s Size: %llu Mode: %s\n", |
| 487 | fd_dev->fd_dev_name, fd_dev->fd_dev_size, |
| 488 | (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) ? |
| 489 | "Buffered-WCE" : "O_DSYNC"); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 490 | return bl; |
| 491 | } |
| 492 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 493 | static sector_t fd_get_blocks(struct se_device *dev) |
| 494 | { |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 495 | struct fd_dev *fd_dev = FD_DEV(dev); |
Nicholas Bellinger | cd9323f | 2012-05-16 16:05:26 -0700 | [diff] [blame] | 496 | struct file *f = fd_dev->fd_file; |
| 497 | struct inode *i = f->f_mapping->host; |
| 498 | unsigned long long dev_size; |
| 499 | /* |
| 500 | * When using a file that references an underlying struct block_device, |
| 501 | * ensure dev_size is always based on the current inode size in order |
| 502 | * to handle underlying block_device resize operations. |
| 503 | */ |
| 504 | if (S_ISBLK(i->i_mode)) |
| 505 | dev_size = (i_size_read(i) - fd_dev->fd_block_size); |
| 506 | else |
| 507 | dev_size = fd_dev->fd_dev_size; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 508 | |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 509 | return div_u64(dev_size, dev->dev_attrib.block_size); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 510 | } |
| 511 | |
Christoph Hellwig | 9e999a6 | 2012-10-07 10:55:50 -0400 | [diff] [blame] | 512 | static struct sbc_ops fd_sbc_ops = { |
Christoph Hellwig | 0c2ad7d | 2012-06-17 18:40:52 -0400 | [diff] [blame] | 513 | .execute_rw = fd_execute_rw, |
Christoph Hellwig | ad67f0d | 2012-06-17 18:40:53 -0400 | [diff] [blame] | 514 | .execute_sync_cache = fd_execute_sync_cache, |
Christoph Hellwig | 0c2ad7d | 2012-06-17 18:40:52 -0400 | [diff] [blame] | 515 | }; |
| 516 | |
Christoph Hellwig | de103c9 | 2012-11-06 12:24:09 -0800 | [diff] [blame^] | 517 | static sense_reason_t |
| 518 | fd_parse_cdb(struct se_cmd *cmd) |
Christoph Hellwig | 0c2ad7d | 2012-06-17 18:40:52 -0400 | [diff] [blame] | 519 | { |
Christoph Hellwig | 9e999a6 | 2012-10-07 10:55:50 -0400 | [diff] [blame] | 520 | return sbc_parse_cdb(cmd, &fd_sbc_ops); |
Christoph Hellwig | 0c2ad7d | 2012-06-17 18:40:52 -0400 | [diff] [blame] | 521 | } |
| 522 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 523 | static struct se_subsystem_api fileio_template = { |
| 524 | .name = "fileio", |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 525 | .inquiry_prod = "FILEIO", |
| 526 | .inquiry_rev = FD_VERSION, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 527 | .owner = THIS_MODULE, |
| 528 | .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, |
| 529 | .attach_hba = fd_attach_hba, |
| 530 | .detach_hba = fd_detach_hba, |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 531 | .alloc_device = fd_alloc_device, |
| 532 | .configure_device = fd_configure_device, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 533 | .free_device = fd_free_device, |
Christoph Hellwig | 0c2ad7d | 2012-06-17 18:40:52 -0400 | [diff] [blame] | 534 | .parse_cdb = fd_parse_cdb, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 535 | .set_configfs_dev_params = fd_set_configfs_dev_params, |
| 536 | .show_configfs_dev_params = fd_show_configfs_dev_params, |
Christoph Hellwig | 6f23ac8 | 2012-10-07 10:55:53 -0400 | [diff] [blame] | 537 | .get_device_type = sbc_get_device_type, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 538 | .get_blocks = fd_get_blocks, |
| 539 | }; |
| 540 | |
| 541 | static int __init fileio_module_init(void) |
| 542 | { |
| 543 | return transport_subsystem_register(&fileio_template); |
| 544 | } |
| 545 | |
| 546 | static void fileio_module_exit(void) |
| 547 | { |
| 548 | transport_subsystem_release(&fileio_template); |
| 549 | } |
| 550 | |
| 551 | MODULE_DESCRIPTION("TCM FILEIO subsystem plugin"); |
| 552 | MODULE_AUTHOR("nab@Linux-iSCSI.org"); |
| 553 | MODULE_LICENSE("GPL"); |
| 554 | |
| 555 | module_init(fileio_module_init); |
| 556 | module_exit(fileio_module_exit); |