All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: Adel Gadllah <adel.gadllah@gmail.com>
Cc: linux-scsi@vger.kernel.org, pjones@redhat.com,
	Jens Axboe <jens.axboe@oracle.com>
Subject: Re: [PATCH/RFC] allow userspace to modify scsi command filter on per device basis
Date: Fri, 13 Jun 2008 13:54:48 -0600	[thread overview]
Message-ID: <20080613195448.GA30405@parisc-linux.org> (raw)
In-Reply-To: <6cf6b73e0806131233i53942756j24a00ba18abebb47@mail.gmail.com>

On Fri, Jun 13, 2008 at 09:33:27PM +0200, Adel Gadllah wrote:
> -		if (blk_verify_command(rq->cmd, has_write_perm))
> +		if (blk_cmd_filter_verify_command(bd->cmd_filter, rq->cmd, bd->f_mode))

Could you wrap to 80 columns?

> +static ssize_t rcf_cmds_store(struct blk_scsi_cmd_filter *filter,
> +			      const char *page, size_t count, int rw)
> +{
> +	ssize_t ret = 0;
> +	unsigned long okbits[BLK_SCSI_CMD_PER_LONG], *target_okbits;
> +	int cmd, status, len;
> +	substring_t ss;
> +
> +	memset(&okbits, 0, sizeof (okbits));
> +
> +	for (len = strlen(page); len > 0; len -= 3) {
> +		if (len < 2)
> +			break;
> +		ss.from = (char *) page + ret;
> +		ss.to = (char *) page + ret + 2;
> +		ret+=3;
> +		status = match_hex(&ss, &cmd);
> +		/* either of these cases means invalid input, so do nothing. */
> +		if (status || cmd >= BLK_SCSI_MAX_CMDS)
> +			return -EINVAL;
> +
> +		set_bit(cmd, okbits);

set_bit is atomic.  locked ops can be quite painful on some processors.
Since okbits is local, the atomicity isn't necessary and you can simply
use __set_bit.

> +static void rcf_set_defaults(struct blk_scsi_cmd_filter *filter)
> +{
> +	/* Basic read-only commands */
> +	set_bit(TEST_UNIT_READY, filter->read_ok);

The set_bit vs __set_bit comment also applies here.

> +int blk_register_filter(struct gendisk *disk)
> +{
> +	int ret;
> +	struct blk_scsi_cmd_filter *filter = &disk->cmd_filter;
> +	struct kobject *parent = kobject_get(disk->holder_dir);
> +	
> +	if(!parent) {
> +		return -EBUSY;
> +	}

Normal style would be to write

	if (!parent)
		return -EBUSY;

(though I don't understand why no parent means we're busy)

> +
> +	ret = kobject_init_and_add(&filter->kobj, &rcf_ktype, parent, "%s", "filter");
> +
> +	if (ret < 0)
> +		return ret;
> +
> +	rcf_set_defaults(filter);

Surely we should set the bits before we make the object visible?

> @@ -189,6 +189,7 @@ void add_disk(struct gendisk *disk)
>  			    disk->minors, NULL, exact_match, exact_lock, disk);
>  	register_disk(disk);
>  	blk_register_queue(disk);
> +	blk_register_filter(disk);

We don't need to handle errors here?  Why not?

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

  reply	other threads:[~2008-06-13 19:55 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-13 19:33 [PATCH/RFC] allow userspace to modify scsi command filter on per device basis Adel Gadllah
2008-06-13 19:54 ` Matthew Wilcox [this message]
2008-06-13 20:22   ` Adel Gadllah
2008-06-13 20:23     ` Adel Gadllah
2008-06-14  6:51       ` [PATCH/RFC v2] " Adel Gadllah
2008-06-16  2:55         ` FUJITA Tomonori
2008-06-16  5:49           ` Adel Gadllah
2008-06-16  6:13             ` FUJITA Tomonori
2008-06-16  9:22               ` [PATCH/RFC v3] " Adel Gadllah
2008-06-17 20:14                 ` FUJITA Tomonori
2008-06-17 21:45                   ` Peter Jones
2008-06-17 22:40                     ` FUJITA Tomonori
2008-06-17 22:49                     ` FUJITA Tomonori
2008-06-17 23:01                     ` Douglas Gilbert
2008-06-18  1:13                       ` Pete Wyckoff
2008-06-18  7:33                       ` Adel Gadllah
2008-06-18 14:55                       ` James Smart
2008-06-18 14:56                       ` Peter Jones
2008-06-26 10:10                         ` Adel Gadllah
2008-06-26 10:13                           ` Jens Axboe
2008-06-26 14:36                           ` FUJITA Tomonori
2008-06-26 15:05                             ` Adel Gadllah
2008-06-26 15:08                               ` FUJITA Tomonori
2008-06-26 15:26                                 ` FUJITA Tomonori
2008-07-24  1:11                             ` Dan Williams
2008-07-24  3:31                               ` FUJITA Tomonori
2008-07-26  9:03                                 ` [PATCH 0/3] cmd_filter fixes FUJITA Tomonori
2008-07-26  9:03                                   ` [PATCH 1/3] move cmd_filter from gendisk to request_queue FUJITA Tomonori
2008-07-26  9:03                                     ` [PATCH 2/3] sg: restore command permission for TYPE_SCANNER FUJITA Tomonori
2008-07-26  9:03                                       ` [PATCH 3/3] rename blk_scsi_cmd_filter to blk_cmd_filter FUJITA Tomonori
2008-07-30 20:10                                     ` [PATCH 1/3] move cmd_filter from gendisk to request_queue Peter Jones
2008-07-31  5:13                                       ` FUJITA Tomonori
2008-08-16  5:47                                     ` FUJITA Tomonori
2008-07-27 19:59                                   ` [PATCH 0/3] cmd_filter fixes Adel Gadllah
2008-07-27 20:02                                     ` Adel Gadllah
2008-07-28  2:18                                       ` FUJITA Tomonori
2008-07-30 19:59                                         ` Adel Gadllah
2008-07-31  4:55                                           ` FUJITA Tomonori
2008-07-31  7:18                                             ` Matthew Wilcox
2008-07-31  7:24                                               ` FUJITA Tomonori
2008-07-31 13:04                                                 ` Matthew Wilcox
2008-07-31 15:18                                                   ` FUJITA Tomonori
2008-08-07 18:47                                                     ` Adel Gadllah
2008-08-08  0:20                                                       ` FUJITA Tomonori
2008-08-08  5:54                                                         ` Jens Axboe
2008-08-08  6:11                                                           ` FUJITA Tomonori
2008-08-08  6:15                                                             ` Jens Axboe
2008-08-08  6:29                                                               ` FUJITA Tomonori
2008-08-08  6:35                                                                 ` Jens Axboe
2008-08-08 16:53                                                                   ` [PATCH 1/2] drop vmerge accounting Mikulas Patocka
2008-08-08 17:07                                                                     ` [PATCH 2/2] " Mikulas Patocka
2008-08-15  9:48                                                                       ` Jens Axboe
2008-08-15 18:23                                                                         ` [PATCH 3/4] " Mikulas Patocka
2008-08-22  9:10                                                                           ` Jens Axboe
2008-08-22  9:17                                                                             ` Jens Axboe
2008-08-22 16:58                                                                               ` Mikulas Patocka
2008-08-22 17:05                                                                                 ` Mikulas Patocka
2008-08-22  9:29                                                                           ` Pierre Ossman
2008-08-22  9:33                                                                             ` Jens Axboe
2008-08-22 21:34                                                                               ` Mikulas Patocka
2008-08-22 21:35                                                                               ` [PATCH 4/4] " Mikulas Patocka
2008-08-15 18:26                                                                         ` Mikulas Patocka
2008-08-21  9:26                                                           ` [PATCH 0/3] cmd_filter fixes Adel Gadllah
2008-08-22  9:10                                                             ` Jens Axboe
2008-06-14 20:26   ` [PATCH/RFC] allow userspace to modify scsi command filter on per device basis Jens Axboe

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=20080613195448.GA30405@parisc-linux.org \
    --to=matthew@wil.cx \
    --cc=adel.gadllah@gmail.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=pjones@redhat.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.