mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: "Pavel Machek" <pavel@ucw.cz>
Cc: "Andrew Morton" <akpm@osdl.org>, "Pavel Machek" <pavel@suse.cz>,
	"Dave Jones" <davej@redhat.com>,
	"LKML" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 0/1] swsusp: fix breakage with swap on LVM
Date: Thu, 16 Feb 2006 23:41:16 +0100	[thread overview]
Message-ID: <200602162341.17090.rjw@sisk.pl> (raw)
In-Reply-To: <200602162251.25298.rjw@sisk.pl>

On Thursday 16 February 2006 22:51, Rafael J. Wysocki wrote:
> On Thursday 16 February 2006 17:13, Pavel Machek wrote:
> > -rc3 version looks ok, and we probably want it in asap. -mm
> > version looks a bit long... --p
> 
> That's because it adds a new function + comment.
> 
> I think it's not a good idea to remake mm/swapfile.c:swap_type_of()
> in a -rc3-like fashion, because it is called by the userland interface for
> a different purpose and should not return non-error for the argument
> being zero.

Well, alternatively I can change the userland interface. :-)


Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 kernel/power/user.c |   13 +++++++++----
 mm/swapfile.c       |    6 ++++--
 2 files changed, 13 insertions(+), 6 deletions(-)

Index: linux-2.6.16-rc3-mm1/mm/swapfile.c
===================================================================
--- linux-2.6.16-rc3-mm1.orig/mm/swapfile.c
+++ linux-2.6.16-rc3-mm1/mm/swapfile.c
@@ -428,14 +428,16 @@ int swap_type_of(dev_t device)
 {
 	int i;
 
-	if (!device)
-		return -EINVAL;
 	spin_lock(&swap_lock);
 	for (i = 0; i < nr_swapfiles; i++) {
 		struct inode *inode;
 
 		if (!(swap_info[i].flags & SWP_WRITEOK))
 			continue;
+		if (!device) {
+			spin_unlock(&swap_lock);
+			return i;
+		}
 		inode = swap_info->swap_file->f_dentry->d_inode;
 		if (S_ISBLK(inode->i_mode) &&
 		    device == MKDEV(imajor(inode), iminor(inode))) {
Index: linux-2.6.16-rc3-mm1/kernel/power/user.c
===================================================================
--- linux-2.6.16-rc3-mm1.orig/kernel/power/user.c
+++ linux-2.6.16-rc3-mm1/kernel/power/user.c
@@ -51,7 +51,7 @@ static int snapshot_open(struct inode *i
 	filp->private_data = data;
 	memset(&data->handle, 0, sizeof(struct snapshot_handle));
 	if ((filp->f_flags & O_ACCMODE) == O_RDONLY) {
-		data->swap = swap_type_of(swsusp_resume_device);
+		data->swap = swsusp_resume_device ? swap_type_of(swsusp_resume_device) : -1;
 		data->mode = O_RDONLY;
 	} else {
 		data->swap = -1;
@@ -252,9 +252,14 @@ static int snapshot_ioctl(struct inode *
 			 * User space encodes device types as two-byte values,
 			 * so we need to recode them
 			 */
-			data->swap = swap_type_of(old_decode_dev(arg));
-			if (data->swap < 0)
-				error = -ENODEV;
+			if (old_decode_dev(arg)) {
+				data->swap = swap_type_of(old_decode_dev(arg));
+				if (data->swap < 0)
+					error = -ENODEV;
+			} else {
+				data->swap = -1;
+				error = -EINVAL;
+			}
 		} else {
 			error = -EPERM;
 		}

  reply	other threads:[~2006-02-16 22:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060216161300.0C667194045@smtp.etmail.cz>
2006-02-16 21:51 ` Rafael J. Wysocki
2006-02-16 22:41   ` Rafael J. Wysocki [this message]
2006-02-18 14:51     ` Pavel Machek
2006-02-18 23:16       ` Rafael J. Wysocki
2006-02-16 14:58 Rafael J. Wysocki

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=200602162341.17090.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@osdl.org \
    --cc=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    --cc=pavel@ucw.cz \
    /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

Powered by JetHome