[PATCH 3/5] target: move sync_cache to struct spc_ops.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Index: lio-core/drivers/target/target_core_file.c
===================================================================
--- lio-core.orig/drivers/target/target_core_file.c	2012-06-17 23:25:58.843873170 +0200
+++ lio-core/drivers/target/target_core_file.c	2012-06-17 23:37:54.423891488 +0200
@@ -331,7 +331,7 @@ static int fd_do_writev(struct se_cmd *c
 	return 1;
 }
 
-static void fd_emulate_sync_cache(struct se_cmd *cmd)
+static int fd_execute_sync_cache(struct se_cmd *cmd)
 {
 	struct se_device *dev = cmd->se_dev;
 	struct fd_dev *fd_dev = dev->dev_ptr;
@@ -365,7 +365,7 @@ static void fd_emulate_sync_cache(struct
 		pr_err("FILEIO: vfs_fsync_range() failed: %d\n", ret);
 
 	if (immed)
-		return;
+		return 0;
 
 	if (ret) {
 		cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
@@ -373,6 +373,8 @@ static void fd_emulate_sync_cache(struct
 	} else {
 		target_complete_cmd(cmd, SAM_STAT_GOOD);
 	}
+
+	return 0;
 }
 
 static int fd_execute_rw(struct se_cmd *cmd)
@@ -554,6 +556,7 @@ static sector_t fd_get_blocks(struct se_
 
 static struct spc_ops fd_spc_ops = {
 	.execute_rw		= fd_execute_rw,
+	.execute_sync_cache	= fd_execute_sync_cache,
 };
 
 static int fd_parse_cdb(struct se_cmd *cmd)
@@ -573,7 +576,6 @@ static struct se_subsystem_api fileio_te
 	.create_virtdevice	= fd_create_virtdevice,
 	.free_device		= fd_free_device,
 	.parse_cdb		= fd_parse_cdb,
-	.do_sync_cache		= fd_emulate_sync_cache,
 	.check_configfs_dev_params = fd_check_configfs_dev_params,
 	.set_configfs_dev_params = fd_set_configfs_dev_params,
 	.show_configfs_dev_params = fd_show_configfs_dev_params,
Index: lio-core/drivers/target/target_core_iblock.c
===================================================================
--- lio-core.orig/drivers/target/target_core_iblock.c	2012-06-17 23:25:53.503873031 +0200
+++ lio-core/drivers/target/target_core_iblock.c	2012-06-17 23:37:16.667890383 +0200
@@ -296,7 +296,7 @@ static void iblock_end_io_flush(struct b
  * Implement SYCHRONIZE CACHE.  Note that we can't handle lba ranges and must
  * always flush the whole cache.
  */
-static void iblock_emulate_sync_cache(struct se_cmd *cmd)
+static int iblock_execute_sync_cache(struct se_cmd *cmd)
 {
 	struct iblock_dev *ib_dev = cmd->se_dev->dev_ptr;
 	int immed = (cmd->t_task_cdb[1] & 0x2);
@@ -315,6 +315,7 @@ static void iblock_emulate_sync_cache(st
 	if (!immed)
 		bio->bi_private = cmd;
 	submit_bio(WRITE_FLUSH, bio);
+	return 0;
 }
 
 static int iblock_do_discard(struct se_device *dev, sector_t lba, u32 range)
@@ -667,6 +668,7 @@ static void iblock_bio_done(struct bio *
 
 static struct spc_ops iblock_spc_ops = {
 	.execute_rw		= iblock_execute_rw,
+	.execute_sync_cache	= iblock_execute_sync_cache,
 };
 
 static int iblock_parse_cdb(struct se_cmd *cmd)
@@ -687,7 +689,6 @@ static struct se_subsystem_api iblock_te
 	.free_device		= iblock_free_device,
 	.parse_cdb		= iblock_parse_cdb,
 	.do_discard		= iblock_do_discard,
-	.do_sync_cache		= iblock_emulate_sync_cache,
 	.check_configfs_dev_params = iblock_check_configfs_dev_params,
 	.set_configfs_dev_params = iblock_set_configfs_dev_params,
 	.show_configfs_dev_params = iblock_show_configfs_dev_params,
Index: lio-core/drivers/target/target_core_sbc.c
===================================================================
--- lio-core.orig/drivers/target/target_core_sbc.c	2012-06-17 23:23:45.619869759 +0200
+++ lio-core/drivers/target/target_core_sbc.c	2012-06-17 23:36:39.763889571 +0200
@@ -204,19 +204,6 @@ static int sbc_emulate_write_same(struct
 	return 0;
 }
 
-static int sbc_emulate_synchronize_cache(struct se_cmd *cmd)
-{
-	if (!cmd->se_dev->transport->do_sync_cache) {
-		pr_err("SYNCHRONIZE_CACHE emulation not supported"
-			" for: %s\n", cmd->se_dev->transport->name);
-		cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE;
-		return -ENOSYS;
-	}
-
-	cmd->se_dev->transport->do_sync_cache(cmd);
-	return 0;
-}
-
 static int sbc_emulate_verify(struct se_cmd *cmd)
 {
 	target_complete_cmd(cmd, GOOD);
@@ -541,6 +528,9 @@ int sbc_parse_cdb(struct se_cmd *cmd, st
 		break;
 	case SYNCHRONIZE_CACHE:
 	case SYNCHRONIZE_CACHE_16:
+		if (!ops->execute_sync_cache)
+			goto out_unsupported_cdb;
+
 		/*
 		 * Extract LBA and range to be flushed for emulated SYNCHRONIZE_CACHE
 		 */
@@ -562,7 +552,7 @@ int sbc_parse_cdb(struct se_cmd *cmd, st
 			if (sbc_check_valid_sectors(cmd) < 0)
 				goto out_invalid_cdb_field;
 		}
-		cmd->execute_cmd = sbc_emulate_synchronize_cache;
+		cmd->execute_cmd = ops->execute_sync_cache;
 		break;
 	case UNMAP:
 		size = get_unaligned_be16(&cdb[7]);
Index: lio-core/include/target/target_core_backend.h
===================================================================
--- lio-core.orig/include/target/target_core_backend.h	2012-06-17 23:29:48.355879044 +0200
+++ lio-core/include/target/target_core_backend.h	2012-06-17 23:36:10.887888840 +0200
@@ -27,7 +27,6 @@ struct se_subsystem_api {
 
 	int (*parse_cdb)(struct se_cmd *cmd);
 	int (*do_discard)(struct se_device *, sector_t, u32);
-	void (*do_sync_cache)(struct se_cmd *);
 	ssize_t (*check_configfs_dev_params)(struct se_hba *,
 			struct se_subsystem_dev *);
 	ssize_t (*set_configfs_dev_params)(struct se_hba *,
@@ -42,6 +41,7 @@ struct se_subsystem_api {
 
 struct spc_ops {
 	int (*execute_rw)(struct se_cmd *cmd);
+	int (*execute_sync_cache)(struct se_cmd *cmd);
 };
 
 int	transport_subsystem_register(struct se_subsystem_api *);

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux