From: Jens Axboe <jens.axboe@oracle.com>
To: Vasily Averin <vvs@sw.ru>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
devel@openvz.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: i2o: CONFIG_DEBUG_SG compilation fixed
Date: Mon, 29 Oct 2007 09:58:44 +0100 [thread overview]
Message-ID: <20071029085844.GC5467@kernel.dk> (raw)
In-Reply-To: <47257E6D.30403@sw.ru>
On Mon, Oct 29 2007, Vasily Averin wrote:
> i2o crashed when CONFIG_DEBUG_SG is enabled because i2o_block_request structure
> includes array of scatterlists that should be initialised
>
> Signed-off-by: Vasily Averin <vvs@sw.ru>
> --- a/drivers/message/i2o/i2o_block.c
> +++ b/drivers/message/i2o/i2o_block.c
> @@ -1137,6 +1137,18 @@ static struct i2o_driver i2o_block_driver = {
> *
> * Returns 0 on success or negative error code on failure.
> */
> +
> +#ifdef CONFIG_DEBUG_SG
> +static void i2o_block_req_ctor(struct kmem_cache *cachep, void *objp) {
> + sg_init_table(((struct i2o_block_request *)(objp))->sg_table,
> + I2O_MAX_PHYS_SEGMENTS);
> +}
> +
> +#define I2O_BLK_CTOR &i2o_block_req_ctor
> +#else
> +#define I2O_BLK_CTOR NULL
> +#endif
> +
> static int __init i2o_block_init(void)
> {
> int rc;
> @@ -1147,7 +1159,7 @@ static int __init i2o_block_init(void)
> /* Allocate request mempool and slab */
> size = sizeof(struct i2o_block_request);
> i2o_blk_req_pool.slab = kmem_cache_create("i2o_block_req", size, 0,
> - SLAB_HWCACHE_ALIGN, NULL);
> + SLAB_HWCACHE_ALIGN, I2O_BLK_CTOR);
> if (!i2o_blk_req_pool.slab) {
> osm_err("can't init request slab\n");
> rc = -ENOMEM;
This should already work, since Oct 24. Your i2o_block_request_alloc()
should look like this:
static inline struct i2o_block_request *i2o_block_request_alloc(void)
{
struct i2o_block_request *ireq;
ireq = mempool_alloc(i2o_blk_req_pool.pool, GFP_ATOMIC);
if (!ireq)
return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&ireq->queue);
sg_init_table(ireq->sg_table, I2O_MAX_PHYS_SEGMENTS);
return ireq;
}
Note that I also don't like your solution, no need to change this to be
a constructor setup and you definitely should not guard sg_init_table()
with CONFIG_DEBUG_SG. It needs to be done always.
--
Jens Axboe
prev parent reply other threads:[~2007-10-29 9:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-29 6:32 i2o: CONFIG_DEBUG_SG compilation fixed Vasily Averin
2007-10-29 8:58 ` Jens Axboe [this message]
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=20071029085844.GC5467@kernel.dk \
--to=jens.axboe@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=devel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vvs@sw.ru \
/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