All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@zip.com.au>
To: Urban Widmark <urban@teststation.com>
Cc: Christoph Hellwig <hch@infradead.org>, Steve Lord <lord@sgi.com>,
	Anton Altaparmakov <aia21@cantab.net>,
	linux-fsdevel@vger.kernel.org
Subject: Re: fs requirements for loop device?
Date: Mon, 13 May 2002 16:47:39 -0700	[thread overview]
Message-ID: <3CE0509B.478F6D18@zip.com.au> (raw)
In-Reply-To: Pine.LNX.4.33.0205140100390.6450-100000@cola.enlightnet.local

Urban Widmark wrote:
> 
> On Mon, 13 May 2002, Andrew Morton wrote:
> 
> > Can anyone point at a reason why loop shouldn't use the
> > ->read() and ->write() methods of the backing file's
> > file_operations?
> 
> The patch below is my naive implementation of that for 2.4.18.
> 
> ...

 loop.c |  113 +++++++++++------------------------------------------------------
 1 files changed, 20 insertions, 93 deletions

that's a good sign ;)

> ...
> +       fs = get_fs();
> +       set_fs(get_ds());
> +       ret = file->f_op->write(file, data, len, &pos);
> +       set_fs(fs);

f_op->write() returns the number of bytes written, or a negative
errno.   So you'll need

	if (ret > 0)
		ret = 0;

in there.

Also it may be nicer to copy `pos' into a local when you
call ->read and ->write, just to avoid altering your callers'
locals, and potentially surprising them (it's OK at present,
so minor point).

> ...
> +       /* This looks strange, if someone free's lo won't they also fput
> +          lo_backing_file? */
>         spin_lock_irq(&lo->lo_lock);
>         file = lo->lo_backing_file;
>         spin_unlock_irq(&lo->lo_lock);

They do.  loop_clr_fd() does fput().

If this code is trying to actually do something legitimate
then clearly it is doing it wrongly.  Just delete the locking
I think.

This is a big improvement to loop.  Let's try to get
this into 2.4.20.


-

  reply	other threads:[~2002-05-13 23:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.33.0205131610410.1822-100000@cola.enlightnet.lo cal>
2002-05-13 14:36 ` fs requirements for loop device? Anton Altaparmakov
2002-05-13 14:43   ` Steve Lord
2002-05-13 16:41     ` Christoph Hellwig
2002-05-13 21:43       ` Andrew Morton
2002-05-13 23:21         ` Urban Widmark
2002-05-13 23:47           ` Andrew Morton [this message]
2002-05-13 23:58             ` Alexander Viro
2002-05-14  0:13               ` Andrew Morton
2002-05-14  7:01                 ` Christoph Hellwig
2002-05-14  9:20             ` Urban Widmark
2002-05-13 14:24 Urban Widmark

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=3CE0509B.478F6D18@zip.com.au \
    --to=akpm@zip.com.au \
    --cc=aia21@cantab.net \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=lord@sgi.com \
    --cc=urban@teststation.com \
    /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.