[PATCH 2/2] tgtd: Patch to add bsoflags update option on tgtd.

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

 



From: Daniel Henrique Debonzi <debonzi@xxxxxxxxxxxxxxxxxx>

This patch make possible to update the bsoflags defined when creating a volume.
User can use "sync","direct","sync:direct" or "none" if he wants to cleanup
the first created bsoflags.

Signed-off-by: Daniel Henrique Debonzi <debonzi@xxxxxxxxxxxxxxxxxx>
---
 usr/spc.c    |   17 +++++++++++++++++
 usr/tgtadm.c |    1 +
 usr/util.c   |    6 ++++++
 3 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/usr/spc.c b/usr/spc.c
index 22fa975..73ba104 100644
--- a/usr/spc.c
+++ b/usr/spc.c
@@ -1679,6 +1679,23 @@ int lu_config(struct scsi_lu *lu, char *params, match_fn_t *fn)
 			match_strncpy(buf, &args[0], sizeof(buf));
 			err = tgt_device_path_update(lu->tgt, lu, buf);
 			break;
+		case Opt_bsoflags:
+			if (!lu->bst->bs_oflags_supported) {
+				eprintf("bsoflags option not supported\n");
+				err = TGTADM_INVALID_REQUEST;
+				break;
+			}
+			match_strncpy(buf, &args[0], sizeof(buf));
+			lu_bsoflags = str_to_open_flags(buf);
+			if (lu_bsoflags == -1) {
+				err = TGTADM_INVALID_REQUEST;
+				break;
+			}
+			lu->bsoflags = lu_bsoflags;
+			/* Keep the same path and update only the flags. */
+			strcpy(buf, lu->path);
+			err = tgt_device_path_update(lu->tgt, lu, buf);
+			break;
 		default:
 			err |= fn ? fn(lu, p) : TGTADM_INVALID_REQUEST;
 		}
diff --git a/usr/tgtadm.c b/usr/tgtadm.c
index d032aaf..8d9012c 100644
--- a/usr/tgtadm.c
+++ b/usr/tgtadm.c
@@ -163,6 +163,7 @@ Linux SCSI Target Framework Administration Utility, version %s\n\
                         bstype option is optional.\n\
                         bsoflags supported options are sync and direct\n\
                         (sync:direct for both).\n\
+                        Use \"none\" to update with no flags. It is optional.\n\
   --lld [driver] --mode logicalunit --op delete --tid=[id] --lun=[lun]\n\
                         delete the specific logical unit with [lun] that\n\
                         the target with [id] has.\n\
diff --git a/usr/util.c b/usr/util.c
index fdd1805..cee4889 100644
--- a/usr/util.c
+++ b/usr/util.c
@@ -150,6 +150,10 @@ int str_to_open_flags(char *buf)
 			open_flags |= O_SYNC;
 		else if (!strncmp(bsoflags_tok, "direct", 6))
 			open_flags |= O_DIRECT;
+		else if (!strncmp(bsoflags_tok, "none", 4)) {
+			open_flags = 0;
+			break;
+		}
 		else {
 			eprintf("bsoflag option %s not supported\n",
 				bsoflags_tok);
@@ -166,6 +170,8 @@ char *open_flags_to_str(char *dest, int flags)
 {
 	*dest = '\0';
 
+	if (flags == 0)
+		strcat(dest, "none");
 	if (flags & O_SYNC)
 		strcat(dest, "sync");
 	if (flags & O_DIRECT) {
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe stgt" 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]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux