linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Danil Kipnis <danil.kipnis@cloud.ionos.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Jack Wang <jinpu.wang@cloud.ionos.com>,
	linux-block@vger.kernel.org, linux-rdma@vger.kernel.org,
	Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@infradead.org>,
	Sagi Grimberg <sagi@grimberg.me>,
	Leon Romanovsky <leon@kernel.org>,
	Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Pankaj Gupta <pankaj.gupta@cloud.ionos.com>
Subject: Re: [PATCH v11 23/26] block/rnbd: server: sysfs interface functions
Date: Mon, 30 Mar 2020 15:14:46 +0200	[thread overview]
Message-ID: <CAHg0HuxsSJzth9iBotNSKJOG4327xRgSRgvaTMH6G58ADSXCTQ@mail.gmail.com> (raw)
In-Reply-To: <8ecc1c47-bad0-dadb-7861-8776b89f0174@acm.org>

On Sat, Mar 28, 2020 at 8:31 PM Bart Van Assche <bvanassche@acm.org> wrote:
>
> On 2020-03-20 05:16, Jack Wang wrote:
> > This is the sysfs interface to rnbd mapped devices on server side:
> >
> >   /sys/devices/virtual/rnbd-server/ctl/devices/<device_name>/
> >     |- block_dev
> >     |  *** link pointing to the corresponding block device sysfs entry
> >     |
> >     |- sessions/<session-name>/
> >     |  *** sessions directory
> >        |
> >        |- read_only
> >        |  *** is devices mapped as read only
> >        |
> >        |- mapping_path
> >           *** relative device path provided by the client during mapping
> >
>
> > +static struct kobj_type ktype = {
> > +     .sysfs_ops      = &kobj_sysfs_ops,
> > +};
>
> From Documentation/kobject.txt: "One important point cannot be
> overstated: every kobject must have a release() method." I think this is
> something that Greg KH feels very strongly about. Please fix this.

OK.


>
> > +int rnbd_srv_create_dev_sysfs(struct rnbd_srv_dev *dev,
> > +                            struct block_device *bdev,
> > +                            const char *dir_name)
> > +{
> > +     struct kobject *bdev_kobj;
> > +     int ret;
> > +
> > +     ret = kobject_init_and_add(&dev->dev_kobj, &ktype,
> > +                                rnbd_devs_kobj, dir_name);
> > +     if (ret)
> > +             return ret;
> > +
> > +     ret = kobject_init_and_add(&dev->dev_sessions_kobj,
> > +                                &ktype,
> > +                                &dev->dev_kobj, "sessions");
> > +     if (ret)
> > +             goto err;
> > +
> > +     bdev_kobj = &disk_to_dev(bdev->bd_disk)->kobj;
> > +     ret = sysfs_create_link(&dev->dev_kobj, bdev_kobj, "block_dev");
> > +     if (ret)
> > +             goto err2;
> > +
> > +     return 0;
> > +
> > +err2:
> > +     kobject_put(&dev->dev_sessions_kobj);
> > +err:
> > +     kobject_put(&dev->dev_kobj);
> > +     return ret;
> > +}
>
> Please choose more descriptive names for the goto labels, e.g.
> put_sess_kobj and put_dev_kobj.

OK


>
> > +static ssize_t read_only_show(struct kobject *kobj, struct kobj_attribute *attr,
> > +                           char *page)
> > +{
> > +     struct rnbd_srv_sess_dev *sess_dev;
> > +
> > +     sess_dev = container_of(kobj, struct rnbd_srv_sess_dev, kobj);
> > +
> > +     return scnprintf(page, PAGE_SIZE, "%s\n",
> > +                      (sess_dev->open_flags & FMODE_WRITE) ? "0" : "1");
> > +}
>
> The scnprintf() statement looks overcomplicated. How about the following?
>
> return scnprintf(page, PAGE_SIZE, "%d\n",
>                  (sess_dev->open_flags & FMODE_WRITE) != 0);

Looks better, thanks.


> > +void rnbd_srv_destroy_dev_session_sysfs(struct rnbd_srv_sess_dev *sess_dev)
> > +{
> > +     DECLARE_COMPLETION_ONSTACK(sysfs_compl);
> > +
> > +     sysfs_remove_group(&sess_dev->kobj,
> > +                        &rnbd_srv_default_dev_session_attr_group);
> > +
> > +     sess_dev->sysfs_release_compl = &sysfs_compl;
> > +     kobject_del(&sess_dev->kobj);
> > +     kobject_put(&sess_dev->kobj);
> > +     wait_for_completion(&sysfs_compl);
> > +}
>
> Why is there a wait_for_completion() call in the above function? I think
> Greg KH strongly disagrees with such calls in functions that remove
> sysfs attributes.

This just makes the function wait until the sysfs release function is
called, so that sess_dev can be freed afterwards. Will try to get rid
of the completion and call the rnbd_destroy_sess_dev() which frees the
struct directly from the release function.


>
> > +int rnbd_srv_create_sysfs_files(void)
> > +{
> > +     int err;
> > +
> > +     rnbd_dev_class = class_create(THIS_MODULE, "rnbd-server");
> > +     if (IS_ERR(rnbd_dev_class))
> > +             return PTR_ERR(rnbd_dev_class);
> > +
> > +     rnbd_dev = device_create(rnbd_dev_class, NULL,
> > +                               MKDEV(0, 0), NULL, "ctl");
> > +     if (IS_ERR(rnbd_dev)) {
> > +             err = PTR_ERR(rnbd_dev);
> > +             goto cls_destroy;
> > +     }
> > +     rnbd_devs_kobj = kobject_create_and_add("devices", &rnbd_dev->kobj);
> > +     if (!rnbd_devs_kobj) {
> > +             err = -ENOMEM;
> > +             goto dev_destroy;
> > +     }
> > +
> > +     return 0;
> > +
> > +dev_destroy:
> > +     device_destroy(rnbd_dev_class, MKDEV(0, 0));
> > +cls_destroy:
> > +     class_destroy(rnbd_dev_class);
> > +
> > +     return err;
> > +}
>
> Please mention the device class in the description of this patch.

OK,

Thanks,

Danil
>
> Thanks,
>
> Bart.

  parent reply	other threads:[~2020-03-30 13:14 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20 12:16 [PATCH v11 00/26] RTRS (former IBTRS) RDMA Transport Library and RNBD (former IBNBD) RDMA Network Block Device Jack Wang
2020-03-20 12:16 ` [PATCH v11 01/26] sysfs: export sysfs_remove_file_self() Jack Wang
2020-03-20 12:16 ` [PATCH v11 02/26] RDMA/rtrs: public interface header to establish RDMA connections Jack Wang
2020-03-20 12:16 ` [PATCH v11 03/26] RDMA/rtrs: private headers with rtrs protocol structs and helpers Jack Wang
2020-03-20 12:16 ` [PATCH v11 04/26] RDMA/rtrs: core: lib functions shared between client and server modules Jack Wang
2020-03-28  4:26   ` Bart Van Assche
2020-03-30 10:34     ` Jinpu Wang
2020-03-30 22:25       ` Bart Van Assche
2020-03-31  7:11         ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 05/26] RDMA/rtrs: client: private header with client structs and functions Jack Wang
2020-03-20 12:16 ` [PATCH v11 06/26] RDMA/rtrs: client: main functionality Jack Wang
2020-03-20 12:16 ` [PATCH v11 07/26] RDMA/rtrs: client: statistics functions Jack Wang
2020-03-20 12:16 ` [PATCH v11 08/26] RDMA/rtrs: client: sysfs interface functions Jack Wang
2020-03-30 22:28   ` Bart Van Assche
2020-03-31  7:20     ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 09/26] RDMA/rtrs: server: private header with server structs and functions Jack Wang
2020-03-20 12:16 ` [PATCH v11 10/26] RDMA/rtrs: server: main functionality Jack Wang
2020-03-20 12:16 ` [PATCH v11 11/26] RDMA/rtrs: server: statistics functions Jack Wang
2020-03-20 12:16 ` [PATCH v11 12/26] RDMA/rtrs: server: sysfs interface functions Jack Wang
2020-03-30 22:29   ` Bart Van Assche
2020-03-31  7:13     ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 13/26] RDMA/rtrs: include client and server modules into kernel compilation Jack Wang
2020-03-20 12:16 ` [PATCH v11 14/26] RDMA/rtrs: a bit of documentation Jack Wang
2020-03-20 12:16 ` [PATCH v11 15/26] block: reexport bio_map_kern Jack Wang
2020-03-28  3:58   ` Bart Van Assche
2020-03-28  8:29     ` Christoph Hellwig
2020-03-28 16:16       ` Bart Van Assche
2020-03-29 15:05         ` Christoph Hellwig
2020-03-29 18:08           ` Chaitanya Kulkarni
2020-03-30  6:28             ` hch
2020-03-30 10:44           ` Jinpu Wang
2020-03-30 18:57             ` Chaitanya Kulkarni
2020-03-20 12:16 ` [PATCH v11 16/26] block/rnbd: private headers with rnbd protocol structs and helpers Jack Wang
2020-03-28  4:58   ` Bart Van Assche
2020-03-31  7:32     ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 17/26] block/rnbd: client: private header with client structs and functions Jack Wang
2020-03-28  4:26   ` Bart Van Assche
2020-03-31  9:08     ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 18/26] block/rnbd: client: main functionality Jack Wang
2020-03-28  4:45   ` Bart Van Assche
2020-03-31  9:23     ` Jinpu Wang
2020-04-02 16:27       ` Jinpu Wang
2020-03-28  4:59   ` Bart Van Assche
2020-03-31  9:25     ` Jinpu Wang
2020-03-31 14:12       ` Bart Van Assche
2020-03-31 14:20         ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 19/26] block/rnbd: client: sysfs interface functions Jack Wang
2020-03-28  4:59   ` Bart Van Assche
2020-03-31  9:26     ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 20/26] block/rnbd: server: private header with server structs and functions Jack Wang
2020-03-20 12:16 ` [PATCH v11 21/26] block/rnbd: server: main functionality Jack Wang
2020-03-28 17:40   ` Bart Van Assche
2020-03-31  9:29     ` Jinpu Wang
2020-03-31 15:32       ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 22/26] block/rnbd: server: functionality for IO submission to file or block dev Jack Wang
2020-03-28 18:39   ` Bart Van Assche
2020-03-31 10:06     ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 23/26] block/rnbd: server: sysfs interface functions Jack Wang
2020-03-28 19:31   ` Bart Van Assche
2020-03-28 23:06     ` Jason Gunthorpe
2020-03-30 13:14     ` Danil Kipnis [this message]
2020-03-20 12:16 ` [PATCH v11 24/26] block/rnbd: include client and server modules into kernel compilation Jack Wang
2020-03-28 19:34   ` Bart Van Assche
2020-03-31  7:23     ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 25/26] block/rnbd: a bit of documentation Jack Wang
2020-03-28 19:40   ` Bart Van Assche
2020-03-30 10:17     ` Danil Kipnis
2020-03-20 12:16 ` [PATCH v11 26/26] MAINTAINERS: Add maintainers for RNBD/RTRS modules Jack Wang
2020-03-28 19:40   ` Bart Van Assche
2020-03-30 10:12     ` Danil Kipnis
2020-03-26 17:38 ` [PATCH v11 00/26] RTRS (former IBTRS) RDMA Transport Library and RNBD (former IBNBD) RDMA Network Block Device Jinpu Wang

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=CAHg0HuxsSJzth9iBotNSKJOG4327xRgSRgvaTMH6G58ADSXCTQ@mail.gmail.com \
    --to=danil.kipnis@cloud.ionos.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=dledford@redhat.com \
    --cc=hch@infradead.org \
    --cc=jgg@ziepe.ca \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=leon@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=pankaj.gupta@cloud.ionos.com \
    --cc=sagi@grimberg.me \
    /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;
as well as URLs for NNTP newsgroup(s).