mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Werner Almesberger <wa@almesberger.net>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] loop devices from NFS broken in recent 2.5
Date: Mon, 24 Jun 2002 21:15:13 -0300	[thread overview]
Message-ID: <20020624211513.A5442@almesberger.net> (raw)

Recent 2.5 kernels break loop devices using files on NFS, because
inode->i_sb->s_bdev is NULL, so you get an oops in loop_set_fd.

The patch below fixes this. Note that I'm not entirely sure
whether using i_blksize is really correct. The patch is for
2.5.24.

This patch also removes redundant setting of LO_FLAGS_READ_ONLY

- Werner

---------------------------------- cut here -----------------------------------

--- drivers/block/loop.c.orig	Sun Jun 23 09:09:10 2002
+++ drivers/block/loop.c	Sun Jun 23 11:41:19 2002
@@ -336,7 +336,10 @@ lo_receive(struct loop_device *lo, struc
 
 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);
+	/* @@@ is this correct ? */
+	return lo->lo_backing_file->f_dentry->d_inode->i_blksize;
 }
 
 static inline unsigned long loop_get_iv(struct loop_device *lo,
@@ -662,9 +665,6 @@ static int loop_set_fd(struct loop_devic
 	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 +691,7 @@ static int loop_set_fd(struct loop_devic
 
 	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 +706,7 @@ static int loop_set_fd(struct loop_devic
 	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;
 	kernel_thread(loop_thread, lo, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);

-- 
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         wa@almesberger.net /
/_http://icapeople.epfl.ch/almesber/_____________________________________/

                 reply	other threads:[~2002-06-25  0:10 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=20020624211513.A5442@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®