From: James Bottomley <James.Bottomley@suse.de>
To: Boaz Harrosh <bharrosh@panasas.com>
Cc: Julia Lawall <julia@diku.dk>,
Doug Gilbert <dgilbert@interlog.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 14/27] drivers/scsi: Use memdup_user
Date: Sun, 23 May 2010 11:22:32 -0500 [thread overview]
Message-ID: <1274631752.5894.24.camel@mulgrave.site> (raw)
In-Reply-To: <4BF94B89.2050101@panasas.com>
On Sun, 2010-05-23 at 18:36 +0300, Boaz Harrosh wrote:
> > This type of transformation has really no value at all. The code you're
> > proposing to replace is already correct. I'm fairly ambivalent on
> > patterned APIs anyway but I accept they're useful way to prevent new
> > code getting it wrong. However, it's completely bogus to force
> > replacement of correctly functioning code throughout the kernel (unless
> > you're going to argue that everyone who tries to copy from user into a
> > kmalloc space does a cut and paste from sg?)
> >
> > Of infinitely greater service would be finding any places where the
> > pattern is being incorrectly used.
> >
>
> It looks like it is not done 100% kosher and calling memdup_user should
> be better.
>
> - For 1 memdup_user does a GFP_KERNEL with a comment on how copy_from_user
> would eventually sleep, so what's the point of GFP_ATOMIC?
Well, since you've written a storage driver, I really hope that question
is rhetorical ...
The reason for using GFP_ATOMIC from user context in storage drivers is
to avoid writeout deadlock: you don't want to trigger a swap write
while you potentially occupy the writeout path. In all older drivers
this had to be GFP_ATOMIC because GFP_NOIO wasn't around.
This also illustrates the problem with design patterns: The idea that
if you have user context, you must be able to kmalloc GFP_KERNEL seems
logical to the people who wrote the pattern, but actually it's
potentially incorrect for storage.
Now in the particular case of sg, I don't believe we'll ever want to
swap over sg (famous last words, of course), so in this instance we
probably could get away with using GFP_KERNEL ... but since it's
following the storage pattern, GFP_ATOMIC (or GFP_NOIO) is correct.
Does osd need auditing for this problem (or would no-one ever do swap
over osd)?
> If this is by design then it surly calls for a comment that explains.
> (I would like to know)
This pattern occurs many times in storage ... documenting it at every
callsite would be a huge waste.
James
next prev parent reply other threads:[~2010-05-23 16:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-22 8:22 Julia Lawall
2010-05-22 14:24 ` James Bottomley
2010-05-23 15:36 ` Boaz Harrosh
2010-05-23 16:22 ` James Bottomley [this message]
2010-05-25 14:15 ` Boaz Harrosh
2010-05-25 14:58 ` James Bottomley
2010-05-25 22:23 ` Andrew Morton
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=1274631752.5894.24.camel@mulgrave.site \
--to=james.bottomley@suse.de \
--cc=bharrosh@panasas.com \
--cc=dgilbert@interlog.com \
--cc=julia@diku.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.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
all inboxes | Powered by JetHome®