linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Shaohua Li <shli@kernel.org>,
	linux-block@vger.kernel.org, linux-raid@vger.kernel.org
Cc: kernel-team@fb.com, Kyungchan Koh <kyungchan.koh@gmail.com>,
	Kyungchan Koh <kkc6196@fb.com>
Subject: Re: [PATCH 2/5] testb: implement block device operations
Date: Tue, 8 Aug 2017 14:34:16 -0600	[thread overview]
Message-ID: <c8e6bbbd-d938-abb7-1e15-b17ce92d91ba@kernel.dk> (raw)
In-Reply-To: <971572972425927f702b33da37be14a9ab646a94.1501945859.git.shli@fb.com>

On 08/05/2017 09:51 AM, Shaohua Li wrote:
> +static struct testb_page *testb_insert_page(struct testb *testb,
> +	sector_t sector, unsigned long *lock_flag)
> +{
> +	u64 idx;
> +	struct testb_page *t_page;
> +
> +	assert_spin_locked(&testb->t_dev->lock);
> +
> +	t_page = testb_lookup_page(testb, sector, true);
> +	if (t_page)
> +		return t_page;
> +
> +	spin_unlock_irqrestore(&testb->t_dev->lock, *lock_flag);

Passing in lock flags through several functions is kind of iffy. It also
used to break on some architectures, though I don't think that's the
case anymore. The problem is that it usually ends up being a code
locking, instead of a data structure locking. The latter is much
cleaner.

> +static int copy_from_testb(struct testb *testb, struct page *dest,
> +	unsigned int off, sector_t sector, size_t n, unsigned long *lock_flag)

This also gets the lock flags passed in, but doesn't use it.

-- 
Jens Axboe

  reply	other threads:[~2017-08-08 20:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-05 15:51 [PATCH 0/5] block: a virtual block device driver for testing Shaohua Li
2017-08-05 15:51 ` [PATCH 1/5] testb: add interface Shaohua Li
2017-08-05 15:51 ` [PATCH 2/5] testb: implement block device operations Shaohua Li
2017-08-08 20:34   ` Jens Axboe [this message]
2017-08-05 15:51 ` [PATCH 3/5] testb: implement bandwidth control Shaohua Li
2017-08-05 15:51 ` [PATCH 4/5] testb: emulate disk cache Shaohua Li
2017-08-05 15:51 ` [PATCH 5/5] testb: badblock support Shaohua Li
2017-08-06  1:56   ` Dan Williams
2017-08-07  4:39     ` Shaohua Li
2017-08-07  8:29 ` [PATCH 0/5] block: a virtual block device driver for testing Hannes Reinecke
2017-08-07 16:36   ` Shaohua Li
2017-08-08 20:31     ` Jens Axboe
2017-08-08 21:05       ` Shaohua Li
2017-08-08 21:13         ` Jens Axboe
2017-08-08 22:00           ` Bart Van Assche
2017-08-08 22:07             ` Jens Axboe
2017-08-08 22:08             ` 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=c8e6bbbd-d938-abb7-1e15-b17ce92d91ba@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=kernel-team@fb.com \
    --cc=kkc6196@fb.com \
    --cc=kyungchan.koh@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=shli@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;
as well as URLs for NNTP newsgroup(s).