From: Werner Almesberger <wa@almesberger.net>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] loop devices from NFS broken in 2.5
Date: Sun, 6 Oct 2002 19:36:57 -0300 [thread overview]
Message-ID: <20021006193657.B14894@almesberger.net> (raw)
2.5 kernels from ~2.5.24 up to 2.5.40 break loop devices using
files on NFS, because inode->i_sb->s_bdev is NULL, so you get
an oops in loop_set_fd, and recently also in loop_get_status.
The patch below fixes this, and I haven't found any ill
side-effects for non-NFS use. The patch is for 2.5.40.
This patch also removes redundant setting of LO_FLAGS_READ_ONLY
(I've posted a similar patch about three months ago. The only
new things now are the loop_get_status change, and that I'm a
little more confident that my solution works :-)
- Werner
---------------------------------- cut here -----------------------------------
--- linux-2.5.40.orig/drivers/block/loop.c Tue Oct 1 04:07:04 2002
+++ linux-2.5.40/drivers/block/loop.c Sun Oct 6 19:18:37 2002
@@ -333,7 +333,9 @@
static inline int loop_get_bs(struct loop_device *lo)
{
- return block_size(lo->lo_device);
+ if (lo->lo_device)
+ return block_size(lo->lo_device);
+ return lo->lo_backing_file->f_dentry->d_inode->i_blksize;
}
static inline unsigned long loop_get_iv(struct loop_device *lo,
@@ -662,9 +664,6 @@
error = -EINVAL;
inode = file->f_dentry->d_inode;
- if (!(file->f_mode & FMODE_WRITE))
- lo_flags |= LO_FLAGS_READ_ONLY;
-
if (S_ISBLK(inode->i_mode)) {
lo_device = inode->i_bdev;
if (lo_device == bdev) {
@@ -691,7 +690,7 @@
get_file(file);
- if (IS_RDONLY (inode) || bdev_read_only(lo_device)
+ if (IS_RDONLY (inode) || (lo_device && bdev_read_only(lo_device))
|| !(lo_file->f_mode & FMODE_WRITE))
lo_flags |= LO_FLAGS_READ_ONLY;
@@ -706,7 +705,7 @@
lo->old_gfp_mask = inode->i_mapping->gfp_mask;
inode->i_mapping->gfp_mask = GFP_NOIO;
- set_blocksize(bdev, block_size(lo_device));
+ set_blocksize(bdev, loop_get_bs(lo));
lo->lo_bio = lo->lo_biotail = NULL;
@@ -878,7 +877,7 @@
info.lo_number = lo->lo_number;
info.lo_device = stat.dev;
info.lo_inode = stat.ino;
- info.lo_rdevice = lo->lo_device->bd_dev;
+ info.lo_rdevice = lo->lo_device ? lo->lo_device->bd_dev : 0;
info.lo_offset = lo->lo_offset;
info.lo_flags = lo->lo_flags;
strncpy(info.lo_name, lo->lo_name, LO_NAME_SIZE);
--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina wa@almesberger.net /
/_http://www.almesberger.net/____________________________________________/
reply other threads:[~2002-10-06 22:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20021006193657.B14894@almesberger.net \
--to=wa@almesberger.net \
--cc=linux-kernel@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®