From: Vivek Goyal <vgoyal@redhat.com>
To: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Cc: Jiri Kosina <jkosina@suse.cz>,
Andrew Morton <akpm@linux-foundation.org>,
Jens Axboe <axboe@kernel.dk>, Tejun Heo <tj@kernel.org>,
linux-kernel@vger.kernel.org, Ben Hutchings <ben@decadent.org.uk>
Subject: Re: [PATCH 2/2] floppy: error handling fixes on do_floppy_init
Date: Wed, 8 Aug 2012 15:57:30 -0400 [thread overview]
Message-ID: <20120808195730.GG15623@redhat.com> (raw)
In-Reply-To: <1344450293-5557-3-git-send-email-herton.krzesinski@canonical.com>
On Wed, Aug 08, 2012 at 03:24:53PM -0300, Herton Ronaldo Krzesinski wrote:
> While looking at commit 3f9a5aa ("floppy: Cleanup disk->queue before
> caling put_disk() if add_disk() was never called") I noticed some
> problems with the error handling and cleanup:
>
> * missing cleanup (put_disk) if blk_init_queue fails, dr is decremented
> first in the error handling loop
> * if something fails in the add_disk loop, there is no cleanup of
> previous iterations in the error handling.
> * "if (disks[dr]->queue)" check is bogus, when reaching there for each
> dr should exist an queue allocated, and it doesn't take into account
> iterations where add_disk wasn't done, if failure happens in add_disk
> loop.
> * floppy_module_exit doesn't reset queue pointer if add_disk wasn't
> done.
Hey, these seem to be multiple cleanups. Can you break these down into
individual patches. Review becomes easy.
[..]
> + blk_cleanup_queue(disks[dr]->queue);
> + /*
> + * put_disk() may not be paired with add_disk() and
> + * will put queue reference one extra time. fix it.
> + */
> + if (dr > registered || !(allowed_drive_mask & (1 << dr)) ||
> + fdc_state[FDC(dr)].version == FDC_NONE)
> disks[dr]->queue = NULL;
I think checking for FDC_NONE and allowed_drive_mask() in multiple places
is becoming unreadable now. Can we just maintain a separate array to keep
track of disks on which we have called add_disk() and do the cleanup
accordingly.
static unsigned short disk_registered[N_DRIVE];
/* do add_disk */
disk_registered[drive] = 1;
out_put_disk:
while(dr--) {
if (disks[dr]->queue && !disk_registered[dr]) {
blk_cleanup_queue()
disks[dr]->queue = NULL;
}
}
Same disk_registered[] can be used for your other loop of remove drives.
Also it can be used in cleaning up code in floppy_module_exit().
I think this will make code much more readable. Right now this error
handling loop is just getting too complicated.
Thanks
Vivek
next prev parent reply other threads:[~2012-08-08 19:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-08 18:24 Bug fixes for floppy driver Herton Ronaldo Krzesinski
2012-08-08 18:24 ` [PATCH 1/2] floppy: don't call alloc_ordered_workqueue inside the alloc_disk loop Herton Ronaldo Krzesinski
2012-08-08 18:24 ` [PATCH 2/2] floppy: error handling fixes on do_floppy_init Herton Ronaldo Krzesinski
2012-08-08 19:57 ` Vivek Goyal [this message]
2012-08-09 17:32 ` Herton Ronaldo Krzesinski
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=20120808195730.GG15623@redhat.com \
--to=vgoyal@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=ben@decadent.org.uk \
--cc=herton.krzesinski@canonical.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@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 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.