public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] make __bdevname output more similar to bdevname
Date: Sun, 4 May 2003 19:17:09 +0200	[thread overview]
Message-ID: <20030504191709.D10659@lst.de> (raw)

Currently __bdevname walks the obsolete list of block majors to
find a name for the given dev_t and falls back to unknown-block(%u,%u)
if that's not possible.  Replace this with an attempted get_gendisk() +
disk_name.  This means __bdevname can't be called from irq context
anymore, but as all old irq context callers are using bdevname() now
that fine (and I've added a big comment).


--- 1.83/drivers/block/genhd.c	Fri Apr 25 18:16:28 2003
+++ edited/drivers/block/genhd.c	Sun May  4 08:38:05 2003
@@ -52,30 +52,6 @@
 	return major_to_index(MAJOR(dev));
 }
 
-/*
- * __bdevname may be called from interrupts, and must be atomic
- */
-const char *__bdevname(dev_t dev, char *buffer)
-{
-	char *name = "unknown-block";
-	unsigned int major = MAJOR(dev);
-	unsigned int minor = MINOR(dev);
-	int index = major_to_index(major);
-	struct blk_major_name *n;
-	unsigned long flags;
-
-	spin_lock_irqsave(&major_names_lock, flags);
-	for (n = major_names[index]; n; n = n->next)
-		if (n->major == major)
-			break;
-	if (n)
-		name = &(n->name[0]);
-	snprintf(buffer, BDEVNAME_SIZE, "%s(%u,%u)", name, major, minor);
-	spin_unlock_irqrestore(&major_names_lock, flags);
-
-	return buffer;
-}
-
 /* get block device names in somewhat random order */
 int get_blkdev_list(char *p)
 {
--- 1.108/fs/partitions/check.c	Tue Apr 29 17:42:50 2003
+++ edited/fs/partitions/check.c	Sun May  4 08:37:43 2003
@@ -125,6 +112,29 @@
 	return disk_name(bdev->bd_disk, part, buf);
 }
 
+/*
+ * NOTE: this cannot be called from interrupt context.
+ *
+ * But in interrupt context you should really have a struct
+ * block_device anyway and use bdevname() above.
+ */
+const char *__bdevname(dev_t dev, char *buffer)
+{
+	struct gendisk *disk;
+	int part;
+
+	disk = get_gendisk(dev, &part);
+	if (disk) {
+		buffer = disk_name(disk, part, buffer);
+		put_disk(disk);
+	} else {
+		snprintf(buffer, BDEVNAME_SIZE, "unknown-block(%u,%u)",
+				MAJOR(dev), MINOR(dev));
+	}
+
+	return buffer;
+}
+
 static struct parsed_partitions *
 check_partition(struct gendisk *hd, struct block_device *bdev)
 {

                 reply	other threads:[~2003-05-04 17:04 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=20030504191709.D10659@lst.de \
    --to=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox