public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: "Ewan D. Milne" <emilne@redhat.com>
To: linux-nvme@lists.infradead.org
Cc: hch@lst.de, muneendra.kumar@broadcom.com,
	james.smart@broadcom.com, stable@vger.kernel.org
Subject: [PATCH] Revert "nvme-fc: fold t fc_update_appid into fc_appid_store"
Date: Mon,  1 Aug 2022 12:27:13 -0400	[thread overview]
Message-ID: <20220801162713.17324-1-emilne@redhat.com> (raw)

This reverts commit c814153c83a892dfd42026eaa661ae2c1f298792.

The commit c814153c83a8 "nvme-fc: fold t fc_update_appid into fc_appid_store"
changed the userspace interface, because the code that decrements "count"
to remove a trailing '\n' in the parsing results in the decremented value being
incorrectly be returned from the sysfs write.  Fix this by revering the commit.

Cc: stable@vger.kernel.org
Signed-off-by: Ewan D. Milne <emilne@redhat.com>
---
 drivers/nvme/host/fc.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 9987797620b6..27f6dfad5d3b 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -3873,10 +3873,12 @@ static int fc_parse_cgrpid(const char *buf, u64 *id)
 }
 
 /*
- * Parse and update the appid in the blkcg associated with the cgroupid.
+ * fc_update_appid: Parse and update the appid in the blkcg associated with
+ * cgroupid.
+ * @buf: buf contains both cgrpid and appid info
+ * @count: size of the buffer
  */
-static ssize_t fc_appid_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t count)
+static int fc_update_appid(const char *buf, size_t count)
 {
 	u64 cgrp_id;
 	int appid_len = 0;
@@ -3904,6 +3906,17 @@ static ssize_t fc_appid_store(struct device *dev,
 		return ret;
 	return count;
 }
+
+static ssize_t fc_appid_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	int ret  = 0;
+
+	ret = fc_update_appid(buf, count);
+	if (ret < 0)
+		return -EINVAL;
+	return count;
+}
 static DEVICE_ATTR(appid_store, 0200, NULL, fc_appid_store);
 #endif /* CONFIG_BLK_CGROUP_FC_APPID */
 
-- 
2.20.1



             reply	other threads:[~2022-08-01 16:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01 16:27 Ewan D. Milne [this message]
2022-08-01 18:27 ` [PATCH] Revert "nvme-fc: fold t fc_update_appid into fc_appid_store" Christoph Hellwig
2022-08-01 21:03   ` James Smart
2022-08-03  4:38     ` Muneendra Kumar M
2022-08-03 16:34       ` Ewan D. Milne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220801162713.17324-1-emilne@redhat.com \
    --to=emilne@redhat.com \
    --cc=hch@lst.de \
    --cc=james.smart@broadcom.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=muneendra.kumar@broadcom.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox