+++ /dev/null
-From b918397542388de75bd86c32fbfa820e5d629fa9 Mon Sep 17 00:00:00 2001
-From: Eric Sandeen <sandeen@redhat.com>
-Date: Mon, 16 Nov 2009 16:34:51 -0600
-Subject: ext3: Don't update the superblock in ext3_statfs()
-
-From: Eric Sandeen <sandeen@redhat.com>
-
-commit b918397542388de75bd86c32fbfa820e5d629fa9 upstream.
-
-commit a71ce8c6c9bf269b192f352ea555217815cf027e updated ext3_statfs()
-to update the on-disk superblock counters, but modified this buffer
-directly without any journaling of the change. This is one of the
-accesses that was causing the crc errors in journal replay as seen in
-kernel.org bugzilla #14354.
-
-The modifications were originally to keep the sb "more" in sync,
-so that a readonly fsck of the device didn't flag this as an
-error (as often), but apparently e2fsprogs deals with this differently
-now, anyway.
-
-Based on Ted's patch for ext4, which was in turn based on my
-work on that bug and another preliminary patch...
-
-Signed-off-by: Eric Sandeen <sandeen@redhat.com>
-Signed-off-by: Jan Kara <jack@suse.cz>
-Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-
-diff --git a/fs/ext3/super.c b/fs/ext3/super.c
-index 427496c..ca3068f 100644
---- a/fs/ext3/super.c
-+++ b/fs/ext3/super.c
-@@ -2686,13 +2686,11 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
- buf->f_bsize = sb->s_blocksize;
- buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last;
- buf->f_bfree = percpu_counter_sum_positive(&sbi->s_freeblocks_counter);
-- es->s_free_blocks_count = cpu_to_le32(buf->f_bfree);
- buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
- if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
- buf->f_bavail = 0;
- buf->f_files = le32_to_cpu(es->s_inodes_count);
- buf->f_ffree = percpu_counter_sum_positive(&sbi->s_freeinodes_counter);
-- es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
- buf->f_namelen = EXT3_NAME_LEN;
- fsid = le64_to_cpup((void *)es->s_uuid) ^
- le64_to_cpup((void *)es->s_uuid + sizeof(u64));
+++ /dev/null
-From 445d211b0da4e9a6e6d576edff85085c2aaf53df Mon Sep 17 00:00:00 2001
-From: Tejun Heo <tj@kernel.org>
-Date: Mon, 5 Apr 2010 10:33:13 +0900
-Subject: libata: unlock HPA if device shrunk
-
-From: Tejun Heo <tj@kernel.org>
-
-commit 445d211b0da4e9a6e6d576edff85085c2aaf53df upstream.
-
-Some BIOSes don't configure HPA during boot but do so while resuming.
-This causes harddrives to shrink during resume making libata detach
-and reattach them. This can be worked around by unlocking HPA if old
-size equals native size.
-
-Add ATA_DFLAG_UNLOCK_HPA so that HPA unlocking can be controlled
-per-device and update ata_dev_revalidate() such that it sets
-ATA_DFLAG_UNLOCK_HPA and fails with -EIO when the above condition is
-detected.
-
-This patch fixes the following bug.
-
- https://bugzilla.kernel.org/show_bug.cgi?id=15396
-
-Signed-off-by: Tejun Heo <tj@kernel.org>
-Reported-by: Oleksandr Yermolenko <yaa.bta@gmail.com>
-Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
-
----
- drivers/ata/libata-core.c | 74 +++++++++++++++++++++++++++-------------------
- include/linux/libata.h | 1
- 2 files changed, 46 insertions(+), 29 deletions(-)
-
---- a/drivers/ata/libata-core.c
-+++ b/drivers/ata/libata-core.c
-@@ -1493,6 +1493,7 @@ static int ata_hpa_resize(struct ata_dev
- {
- struct ata_eh_context *ehc = &dev->link->eh_context;
- int print_info = ehc->i.flags & ATA_EHI_PRINTINFO;
-+ bool unlock_hpa = ata_ignore_hpa || dev->flags & ATA_DFLAG_UNLOCK_HPA;
- u64 sectors = ata_id_n_sectors(dev->id);
- u64 native_sectors;
- int rc;
-@@ -1509,7 +1510,7 @@ static int ata_hpa_resize(struct ata_dev
- /* If device aborted the command or HPA isn't going to
- * be unlocked, skip HPA resizing.
- */
-- if (rc == -EACCES || !ata_ignore_hpa) {
-+ if (rc == -EACCES || !unlock_hpa) {
- ata_dev_printk(dev, KERN_WARNING, "HPA support seems "
- "broken, skipping HPA handling\n");
- dev->horkage |= ATA_HORKAGE_BROKEN_HPA;
-@@ -1524,7 +1525,7 @@ static int ata_hpa_resize(struct ata_dev
- dev->n_native_sectors = native_sectors;
-
- /* nothing to do? */
-- if (native_sectors <= sectors || !ata_ignore_hpa) {
-+ if (native_sectors <= sectors || !unlock_hpa) {
- if (!print_info || native_sectors == sectors)
- return 0;
-
-@@ -4180,36 +4181,51 @@ int ata_dev_revalidate(struct ata_device
- goto fail;
-
- /* verify n_sectors hasn't changed */
-- if (dev->class == ATA_DEV_ATA && n_sectors &&
-- dev->n_sectors != n_sectors) {
-- ata_dev_printk(dev, KERN_WARNING, "n_sectors mismatch "
-- "%llu != %llu\n",
-- (unsigned long long)n_sectors,
-- (unsigned long long)dev->n_sectors);
-- /*
-- * Something could have caused HPA to be unlocked
-- * involuntarily. If n_native_sectors hasn't changed
-- * and the new size matches it, keep the device.
-- */
-- if (dev->n_native_sectors == n_native_sectors &&
-- dev->n_sectors > n_sectors &&
-- dev->n_sectors == n_native_sectors) {
-- ata_dev_printk(dev, KERN_WARNING,
-- "new n_sectors matches native, probably "
-- "late HPA unlock, continuing\n");
-- /* keep using the old n_sectors */
-- dev->n_sectors = n_sectors;
-- } else {
-- /* restore original n_[native]_sectors and fail */
-- dev->n_native_sectors = n_native_sectors;
-- dev->n_sectors = n_sectors;
-- rc = -ENODEV;
-- goto fail;
-- }
-+ if (dev->class != ATA_DEV_ATA || !n_sectors ||
-+ dev->n_sectors == n_sectors)
-+ return 0;
-+
-+ /* n_sectors has changed */
-+ ata_dev_printk(dev, KERN_WARNING, "n_sectors mismatch %llu != %llu\n",
-+ (unsigned long long)n_sectors,
-+ (unsigned long long)dev->n_sectors);
-+
-+ /*
-+ * Something could have caused HPA to be unlocked
-+ * involuntarily. If n_native_sectors hasn't changed and the
-+ * new size matches it, keep the device.
-+ */
-+ if (dev->n_native_sectors == n_native_sectors &&
-+ dev->n_sectors > n_sectors && dev->n_sectors == n_native_sectors) {
-+ ata_dev_printk(dev, KERN_WARNING,
-+ "new n_sectors matches native, probably "
-+ "late HPA unlock, continuing\n");
-+ /* keep using the old n_sectors */
-+ dev->n_sectors = n_sectors;
-+ return 0;
- }
-
-- return 0;
-+ /*
-+ * Some BIOSes boot w/o HPA but resume w/ HPA locked. Try
-+ * unlocking HPA in those cases.
-+ *
-+ * https://bugzilla.kernel.org/show_bug.cgi?id=15396
-+ */
-+ if (dev->n_native_sectors == n_native_sectors &&
-+ dev->n_sectors < n_sectors && n_sectors == n_native_sectors &&
-+ !(dev->horkage & ATA_HORKAGE_BROKEN_HPA)) {
-+ ata_dev_printk(dev, KERN_WARNING,
-+ "old n_sectors matches native, probably "
-+ "late HPA lock, will try to unlock HPA\n");
-+ /* try unlocking HPA */
-+ dev->flags |= ATA_DFLAG_UNLOCK_HPA;
-+ rc = -EIO;
-+ } else
-+ rc = -ENODEV;
-
-+ /* restore original n_[native_]sectors and fail */
-+ dev->n_native_sectors = n_native_sectors;
-+ dev->n_sectors = n_sectors;
- fail:
- ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc);
- return rc;
---- a/include/linux/libata.h
-+++ b/include/linux/libata.h
-@@ -146,6 +146,7 @@ enum {
- ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */
- ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */
- ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */
-+ ATA_DFLAG_UNLOCK_HPA = (1 << 18), /* unlock HPA */
- ATA_DFLAG_INIT_MASK = (1 << 24) - 1,
-
- ATA_DFLAG_DETACH = (1 << 24),