Revert "nvme-fc: fold t fc_update_appid into fc_appid_store"
Subsystems (3)
PATCH 1/1 Revert "nvme-fc: fold t fc_update_appid into fc_appid_store"
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.
--- drivers/nvme/host/fc.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/nvme/host/fc.c +16 -3
@@ -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 */
Signature · 1 line
2.20.1
Christoph Hellwig
maintainerQuoted 6 lines · Ewan D. Milne
This reverts commit
c814153c83a892dfd42026eaa661ae2c1f298792.The commit
c814153c83a8"nvme-fc: fold tfc_update_appidintofc_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.
Wouldn't something like the patch below be much simpler and cleaner:
drivers/nvme/host/fc.c +2 -1
@@ -3878,6 +3878,7 @@ static int fc_parse_cgrpid(const char *buf, u64 *id)static ssize_t fc_appid_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { +size_t orig_count = count;u64 cgrp_id;int appid_len =0 ;int cgrpid_len =0 ;
@@ -3902,7 +3903,7 @@ static ssize_t fc_appid_store(struct device *dev, ret =blkcg_set_fc_appid (app_id, cgrp_id,sizeof (app_id));if (ret <0 )return ret; -return count; +return orig_count; } static DEVICE_ATTR(appid_store, 0200, NULL, fc_appid_store);#endif /* CONFIG_BLK_CGROUP_FC_APPID */
James Smart
Reviewed-byQuoted 25 lines · Christoph Hellwig
Quoted 6 lines · Ewan D. Milne
This reverts commit
c814153c83a892dfd42026eaa661ae2c1f298792.The commit
c814153c83a8"nvme-fc: fold tfc_update_appidintofc_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.Wouldn't something like the patch below be much simpler and cleaner:
drivers/nvme/host/fc.c +1
-0@@ -3878,6 +3878,7 @@ static int fc_parse_cgrpid(const char *buf, u64 *id)static ssize_t fc_appid_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { +size_t orig_count = count;u64 cgrp_id;int appid_len =0 ;int cgrpid_len =0 ;
drivers/nvme/host/fc.c static ssize_t fc_appid_store(struct device *dev, · line 3909
Quoted 8 lines
drivers/nvme/host/fc.c +1
-1@@ -3902,7 +3903,7 @@ static ssize_t fc_appid_store(struct device *dev, ret =blkcg_set_fc_appid (app_id, cgrp_id,sizeof (app_id));if (ret <0 )return ret; -return count; +return orig_count; } static DEVICE_ATTR(appid_store, 0200, NULL, fc_appid_store);#endif /* CONFIG_BLK_CGROUP_FC_APPID */
looks good on my end.
-- james
I have tested the below changes suggested by Christoph and it is working as expected.
-----Original Message-----
From: James Smart [mailto:[email protected]]
Sent: Tuesday, August 2, 2022 2:33 AM
To: Christoph Hellwig <[email protected]>; Ewan D. Milne <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] Revert "nvme-fc: fold t fc_update_appid into fc_appid_store"
Quoted 27 lines · Christoph Hellwig
Quoted 8 lines · Ewan D. Milne
This reverts commit
c814153c83a892dfd42026eaa661ae2c1f298792.The commit
c814153c83a8"nvme-fc: fold tfc_update_appidintofc_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.Wouldn't something like the patch below be much simpler and cleaner:
drivers/nvme/host/fc.c index renamed from drivers/nvme/host/fc.c +0
-0
9987797620b6d..e24ab688f00d5100644drivers/nvme/host/fc.c +1
-0@@ -3878,6 +3878,7 @@ static int fc_parse_cgrpid(const char *buf, u64 *id)static ssize_t fc_appid_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { +size_t orig_count = count;u64 cgrp_id;int appid_len =0 ;int cgrpid_len =0 ;
drivers/nvme/host/fc.c static ssize_t fc_appid_store(struct device *dev, · line 3909
Quoted 8 lines
drivers/nvme/host/fc.c +1
-1@@ -3902,7 +3903,7 @@ static ssize_t fc_appid_store(struct device *dev, ret =blkcg_set_fc_appid (app_id, cgrp_id,sizeof (app_id));if (ret <0 )return ret; -return count; +return orig_count; } static DEVICE_ATTR(appid_store, 0200, NULL, fc_appid_store);#endif /* CONFIG_BLK_CGROUP_FC_APPID */
looks good on my end.
-- james
Signature · 11 lines
This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.
Ewan D. Milne
Reviewed-byQuoted 6 lines · Muneendra Kumar M
I have tested the below changes suggested by Christoph and it is working as expected.
Tested-by <[email protected]>
Fine with me.