All of lore.kernel.org
 help / color / mirror / Atom feed
From: ckulkarnilinux@gmail.com (chaitany kulkarni)
Subject: [PATCH] blktests: use global configfs variable
Date: Mon, 7 May 2018 13:41:39 -0700	[thread overview]
Message-ID: <CAK0tqinaY_ZJm5WBd_8kRMLFG_6Uw_7XyOy3B9HOsHWfnP=4SA@mail.gmail.com> (raw)
In-Reply-To: <20180507200417.3036-1-chaitanya.kulkarni@wdc.com>

Please drop this one, let me resend this patch.

On Mon, May 7, 2018 at 1:04 PM, Chaitanya Kulkarni
<chaitanya.kulkarni@wdc.com> wrote:
> This patch introduces a global variable to hold the
> configfs nvmet path. Now we don't need repetitive
> local variables to hold the path and testcases
> can use the newly introduced variable if needed.
>
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
> ---
>  common/nvme | 27 +++++++++++----------------
>  1 file changed, 11 insertions(+), 16 deletions(-)
>
> diff --git a/common/nvme b/common/nvme
> index c6718f0..797e6db 100644
> --- a/common/nvme
> +++ b/common/nvme
> @@ -17,6 +17,8 @@
>  # You should have received a copy of the GNU General Public License
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>
> +NVMET_CFS="/sys/kernel/config/nvmet/"
> +
>  _test_dev_is_nvme() {
>         if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q nvme; then
>                 SKIP_REASON="$TEST_DEV is not a NVMe device"
> @@ -27,33 +29,29 @@ _test_dev_is_nvme() {
>
>  _create_nvmet_port() {
>         local trtype="$1"
> -       local nvmet_cfs="/sys/kernel/config/nvmet/"
> -
>         local port
>         for ((port = 0; ; port++)); do
> -               if [[ ! -e "${nvmet_cfs}/${port}" ]]; then
> +               if [[ ! -e "${NVMET_CFG}/${port}" ]]; then
>                         break
>                 fi
>         done
>
> -       mkdir "${nvmet_cfs}/ports/${port}"
> -       echo "${trtype}" > "${nvmet_cfs}/ports/${port}/addr_trtype"
> +       mkdir "${NVMET_CFG}/ports/${port}"
> +       echo "${trtype}" > "${NVMET_CFG}/ports/${port}/addr_trtype"
>
>         echo "${port}"
>  }
>
>  _remove_nvmet_port() {
>         local port="$1"
> -       local nvmet_cfs="/sys/kernel/config/nvmet/"
> -       rmdir "${nvmet_cfs}/ports/${port}"
> +       rmdir "${NVMET_CFG}/ports/${port}"
>  }
>
>  _create_nvmet_subsystem() {
>         local nvmet_subsystem="$1"
>         local blkdev="$2"
>         local uuid="00000000-0000-0000-0000-000000000000"
> -       local nvmet_cfs="/sys/kernel/config/nvmet/"
> -       local cfs_path="${nvmet_cfs}/subsystems/${nvmet_subsystem}"
> +       local cfs_path="${NVMET_CFG}/subsystems/${nvmet_subsystem}"
>
>         if [[ $# -eq 3 ]]; then
>                 uuid="$3"
> @@ -69,8 +67,7 @@ _create_nvmet_subsystem() {
>
>  _remove_nvmet_subsystem() {
>         local nvmet_subsystem="$1"
> -       local nvmet_cfs="/sys/kernel/config/nvmet/"
> -       local cfs_path="${nvmet_cfs}/subsystems/${nvmet_subsystem}"
> +       local cfs_path="${NVMET_CFG}/subsystems/${nvmet_subsystem}"
>
>         echo 0 > "${cfs_path}/namespaces/1/enable"
>         rmdir "${cfs_path}/namespaces/1/"
> @@ -80,16 +77,14 @@ _remove_nvmet_subsystem() {
>  _add_nvmet_subsys_to_port() {
>         local port="$1"
>         local nvmet_subsystem="$2"
> -       local nvmet_cfs="/sys/kernel/config/nvmet/"
>
> -       ln -s "${nvmet_cfs}/subsystems/${nvmet_subsystem}" \
> -               "${nvmet_cfs}/ports/${port}/subsystems/${nvmet_subsystem}"
> +       ln -s "${NVMET_CFG}/subsystems/${nvmet_subsystem}" \
> +               "${NVMET_CFG}/ports/${port}/subsystems/${nvmet_subsystem}"
>  }
>
>  _remove_nvmet_subsystem_from_port() {
>         local port="$1"
>         local nvmet_subsystem="$2"
> -       local nvmet_cfs="/sys/kernel/config/nvmet/"
>
> -       rm "${nvmet_cfs}/ports/${port}/subsystems/${nvmet_subsystem}"
> +       rm "${NVMET_CFG}/ports/${port}/subsystems/${nvmet_subsystem}"
>  }
> --
> 2.9.5
>
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply	other threads:[~2018-05-07 20:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-07 20:04 [PATCH] blktests: use global configfs variable Chaitanya Kulkarni
2018-05-07 20:41 ` chaitany kulkarni [this message]
2018-05-08  5:45 Chaitanya Kulkarni
2018-05-08  6:38 ` Johannes Thumshirn
2018-05-14 20:07 ` Omar Sandoval

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='CAK0tqinaY_ZJm5WBd_8kRMLFG_6Uw_7XyOy3B9HOsHWfnP=4SA@mail.gmail.com' \
    --to=ckulkarnilinux@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.