From: "Holden Karau" <holden@pigscanfly.ca>
To: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
Cc: "Josef Sipek" <jsipek@fsl.cs.sunysb.edu>,
hirofumi@mail.parknet.co.jp, linux-kernel@vger.kernel.org,
"Holden Karau" <holdenk@xandros.com>,
"akpm@osdl.org" <akpm@osdl.org>,
linux-fsdevel@vger.kernel.org,
"Nick Piggin" <nickpiggin@yahoo.com.au>,
"Matthew Wilcox" <matthew@wil.cx>
Subject: Re: [PATCH 1/1] fat: improve sync performance by grouping writes revised again
Date: Wed, 1 Nov 2006 13:02:12 -0500 [thread overview]
Message-ID: <f46018bb0611011002h1b3b6e5fjdc6cc032a7503dbd@mail.gmail.com> (raw)
In-Reply-To: <20061101164715.GC16154@wohnheim.fh-wedel.de>
On 11/1/06, Jörn Engel <joern@wohnheim.fh-wedel.de> wrote:
> On Wed, 1 November 2006 11:17:50 -0500, Holden Karau wrote:
> > + c_bh = kmalloc(nr_bhs*(sbi->fats) , GFP_KERNEL);
> > + if (NULL == c_bh) {
> > + printk(KERN_CRIT "not enough memory to store pointers to FAT blocks, will not sync. Possible data loss\n");
> > + err = -ENOMEM;
> > + goto error;
> > + }
>
> o I personally hate Yoda code ("Null the pointer is not, young Jedi").
> o Old code simply returned -ENOMEM without printk. Assuming this was
> sufficient before, the printk can be dropped.
Ok, I'll drop the printk
> o Some people prefer assigning err outside the condition. It is
> supposed to give slightly better code on i386, iirc.
>
> Result would be something like:
> c_bh = kmalloc(...
> err = -ENOMEM;
> if (!c_bh)
> goto error;
That wouldn't work so well since we always return err, and possibly
slightly better code for i386 doesn't seem all that worth it.
>
> > + for (n = 0 ; n < nr_bhs ; n++ ) {
> > + c_bh[(copy-1)*nr_bhs+n] = sb_getblk(sb, backup_fat + bhs[n]->b_blocknr);
> > + /* If there is not enough memory, fall back to the old system */
> > + if (!c_bh[(copy-1)*nr_bhs+n]) {
> > + printk("fat: not enough memory for all blocks , syncing at %d\n" ,(copy-1)*nr_bhs+n);
>
> Whether this printk makes sense, I cannot tell.
I suppose I might as well drop it.
>
> > + fat_sync_bhs_optw( c_bh+i , (copy-1)*nr_bhs+n-i-1 , wait );
> > + /* Free the now sync'd blocks */
> > + for (; i < (copy-1)*nr_bhs+n ; i++)
> > + brelse(c_bh[i]);
> > + /* We try the same block again */
> > + c_bh[(copy-1)*nr_bhs+n] = sb_getblk(sb, backup_fat + bhs[n]->b_blocknr);
> > + if (!c_bh[(copy-1)*nr_bhs+n]) {
> > + printk(KERN_CRIT "fat:not enough memory for block after existing blocks released. Possible data loss.\n");
Based on the same reasoning you provided, I should probably drop this one too.
> > + err = -ENOMEM;
> > + goto error;
> > + }
>
> As above.
I'll drop the printk, but the same holds true about err
>
> > error:
> > + if (NULL != c_bh) {
> > + kfree(c_bh);
> > + }
>
> kfree(NULL) works just fine. You can remove the condition.
Thanks, I should have checked that :-)
>
> > +int fat_sync_bhs_optw(struct buffer_head **bhs, int nr_bhs ,int wait)
> > {
> > int i, err = 0;
> >
> > ll_rw_block(SWRITE, nr_bhs, bhs);
> > - for (i = 0; i < nr_bhs; i++) {
> > - wait_on_buffer(bhs[i]);
> > - if (buffer_eopnotsupp(bhs[i])) {
> > - clear_buffer_eopnotsupp(bhs[i]);
> > - err = -EOPNOTSUPP;
> > - } else if (!err && !buffer_uptodate(bhs[i]))
> > - err = -EIO;
> > + if (wait) {
> > + for (i = 0; i < nr_bhs; i++) {
> > + wait_on_buffer(bhs[i]);
> > + if (buffer_eopnotsupp(bhs[i])) {
> > + clear_buffer_eopnotsupp(bhs[i]);
> > + err = -EOPNOTSUPP;
> > + } else if (!err && !buffer_uptodate(bhs[i]))
> > + err = -EIO;
> > + }
> > }
> > +
> > return err;
> > }
>
> You could keep the old indentation if your condition was changed to
>
> if (!wait)
> return 0;
Sounds good.
>
> Jörn
>
> --
> You can take my soul, but not my lack of enthusiasm.
> -- Wally
>
--
Cell: 613-276-1645
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2006-11-01 18:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-01 16:17 [PATCH 1/1] fat: improve sync performance by grouping writes revised again Holden Karau
2006-11-01 16:47 ` Jörn Engel
2006-11-01 18:02 ` Holden Karau [this message]
2006-11-01 20:24 ` Jörn Engel
2006-11-01 20:52 ` Phillip Susi
2006-11-01 22:17 ` Holden Karau
2006-11-02 10:24 ` historical micro-optimizations (Re: [PATCH 1/1] fat: improve sync performance by grouping writes revised again) Jörn Engel
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=f46018bb0611011002h1b3b6e5fjdc6cc032a7503dbd@mail.gmail.com \
--to=holden@pigscanfly.ca \
--cc=akpm@osdl.org \
--cc=hirofumi@mail.parknet.co.jp \
--cc=holdenk@xandros.com \
--cc=joern@wohnheim.fh-wedel.de \
--cc=jsipek@fsl.cs.sunysb.edu \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=nickpiggin@yahoo.com.au \
/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).