All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@suse.de>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] take 48-bit lba a bit further
Date: Sun, 6 Apr 2003 15:07:37 +0200	[thread overview]
Message-ID: <20030406130737.GL786@suse.de> (raw)

Hi,

Thanks for taking the previous bit Alan, here's an incremental update to
2.5.66-ac2. Just cleans up the 'when to use 48-bit lba' logic a bit per
Andries suggestion, and also expands the request size for 48-bit lba
capable drives to 512KiB.

Works perfectly in testing here, ext2/3 generates nice big 512KiB
requests and the drive flies.

diff -ur -X /home/axboe/cdrom/exclude /opt/kernel/linux-2.5.66-ac2/drivers/ide/ide-disk.c linux-2.5.66-ac2/drivers/ide/ide-disk.c
--- /opt/kernel/linux-2.5.66-ac2/drivers/ide/ide-disk.c	2003-04-06 13:15:19.000000000 +0200
+++ linux-2.5.66-ac2/drivers/ide/ide-disk.c	2003-04-06 15:05:07.000000000 +0200
@@ -373,7 +373,7 @@
 
 	nsectors.all		= (u16) rq->nr_sectors;
 
-	if (drive->addressing == 1 && block + rq->nr_sectors > 0xfffffff)
+	if (drive->addressing == 1 && rq_lba48(rq))
 		lba48 = 1;
 
 	if (driver_blocked)
@@ -583,7 +583,7 @@
 {
 	int lba48bit = 0;
 
-	if (drive->addressing == 1 && block > 0xfffffff)
+	if (drive->addressing == 1 && rq_lba48(rq))
 		lba48bit = 1;
 
 	BUG_ON(drive->blocked);
@@ -611,7 +611,7 @@
 		return ide_started;
 	}
 
-	if (lba48bit && block > 0xfffffff)
+	if (lba48bit)
 		return lba_48_rw_disk(drive, rq, (unsigned long long) block);
 	if (drive->select.b.lba)		/* 28-bit LBA */
 		return lba_28_rw_disk(drive, rq, (unsigned long) block);
@@ -625,7 +625,7 @@
 	int cmd = rq_data_dir(rq);
 	int lba48bit = 0;
 
-	if (drive->addressing == 1 && rq->sector > 0xfffffff)
+	if (drive->addressing == 1 && rq_lba48(rq))
 		lba48bit = 1;
 
 	if ((cmd == READ) && drive->using_tcq)
@@ -1504,7 +1504,7 @@
 
 static int set_lba_addressing (ide_drive_t *drive, int arg)
 {
-	return (probe_lba_addressing(drive, arg));
+	return probe_lba_addressing(drive, arg);
 }
 
 static void idedisk_add_settings(ide_drive_t *drive)
@@ -1591,6 +1591,9 @@
 
 	(void) probe_lba_addressing(drive, 1);
 
+	if (drive->addressing)
+		blk_queue_max_sectors(&drive->queue, 1024);
+
 	/* Extract geometry if we did not already have one for the drive */
 	if (!drive->cyl || !drive->head || !drive->sect) {
 		drive->cyl     = drive->bios_cyl  = id->cyls;
diff -ur -X /home/axboe/cdrom/exclude /opt/kernel/linux-2.5.66-ac2/drivers/ide/ide-dma.c linux-2.5.66-ac2/drivers/ide/ide-dma.c
--- /opt/kernel/linux-2.5.66-ac2/drivers/ide/ide-dma.c	2003-04-06 13:15:19.000000000 +0200
+++ linux-2.5.66-ac2/drivers/ide/ide-dma.c	2003-04-06 13:19:34.000000000 +0200
@@ -663,7 +663,7 @@
 	if (drive->media != ide_disk)
 		return 0;
 
-	if (drive->addressing == 1 && rq->sector > 0xfffffff)
+	if (drive->addressing == 1 && rq_lba48(rq))
 		lba48 = 1;
 
 	command = (lba48) ? WIN_READDMA_EXT : WIN_READDMA;
@@ -698,7 +698,7 @@
 	if (drive->media != ide_disk)
 		return 0;
 
-	if (drive->addressing == 1 && rq->sector > 0xfffffff)
+	if (drive->addressing == 1 && rq_lba48(rq))
 		lba48 = 1;
 
 	command = (lba48) ? WIN_WRITEDMA_EXT : WIN_WRITEDMA;
diff -ur -X /home/axboe/cdrom/exclude /opt/kernel/linux-2.5.66-ac2/include/linux/ide.h linux-2.5.66-ac2/include/linux/ide.h
--- /opt/kernel/linux-2.5.66-ac2/include/linux/ide.h	2003-04-06 13:15:20.000000000 +0200
+++ linux-2.5.66-ac2/include/linux/ide.h	2003-04-06 13:20:25.000000000 +0200
@@ -866,6 +866,12 @@
 		bio_kunmap_irq(buffer, flags);
 }
 
+/*
+ * must be addressed with 48-bit lba
+ */
+#define rq_lba48(rq)	\
+	(((rq)->sector + (rq)->nr_sectors) > 0xfffffff || rq->nr_sectors > 256)
+
 #define IDE_CHIPSET_PCI_MASK	\
     ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx))
 #define IDE_CHIPSET_IS_PCI(c)	((IDE_CHIPSET_PCI_MASK >> (c)) & 1)

-- 
Jens Axboe


             reply	other threads:[~2003-04-06 12:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-06 13:07 Jens Axboe [this message]
2003-04-06 13:32 ` [PATCH] take 48-bit lba a bit further John Bradford
2003-04-06 13:32   ` Jens Axboe
2003-04-06 14:35   ` Alan Cox
2003-04-06 15:47     ` John Bradford
2003-04-06 15:59       ` Jens Axboe
2003-04-06 16:04         ` Jens Axboe
2003-04-06 16:08         ` John Bradford
2003-04-06 16:43 ` Petr Vandrovec
2003-04-06 16:27   ` Alan Cox
2003-04-07  7:50     ` Jens Axboe
     [not found] <175955253@toto.iv>
2003-04-06 23:04 ` Peter Chubb

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=20030406130737.GL786@suse.de \
    --to=axboe@suse.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --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 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.