Suspending with mounted ext3 formatted SD card erases partition table (karmic regression)

Bug #383668 reported by Stefan Bader
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Fix Released
High
Stefan Bader

Bug Description

Kernel: 2.6.30-rc7 based
Worked in Jaunty (probably only because things went at a different speed)

Testcase: Use ext3/ext4 on a SD card partitioned with one primary DOS partition and leave it mounted while suspend/resume.

Result: After resume the partition table of the SD card has been erased.

In more detail: This is my assumption based on some debugging done.

On suspend the mmc block device gets thrown away. Parts of that is mmc_blk_remove which calls mmc_cleanup_queue. There blk_cleanup_queue is called which should end the lifetime of the queue object (which seems to be done).

The bad part is that gendisk struct holds a reference to that queue object which is never accounted for. And the gendisk struct is kept together with the mmc device structure as long as that is opened (done on mount).
As the device triggers the removal it seems to take a bit of time until the old mount is thrown away. In fact it looks like this is spread between suspend and resume.

What makes the whole thing a disaster is the fact that the block device queue objects are taken from a slub cache. Which means on resume, the newly created block device will get the same queue object as the old one, initializes it and
after the tasks have been resumed, ext3 feels obliged to write out the invalidated superblocks (still not sure why it goes for sector 0) which will happily migrate to the new block device and cause confusion.

Revision history for this message
Stefan Bader (smb) wrote :

The first log is a debugging long of the state before. The block device request queue gets set up twice then there is a WARNING at the point when sector 0 gets overwritten by a request coming from the old device.

Changed in linux (Ubuntu):
assignee: nobody → Stefan Bader (stefan-bader-canonical)
importance: Undecided → High
status: New → In Progress
Revision history for this message
Stefan Bader (smb) wrote :
Revision history for this message
Stefan Bader (smb) wrote :

With the patch the forced unmount of ext3 still wants to write out some data before closing the block device but this time the requests get rejected.

Probably this is not the behavior intended but it seems to be the safe approach.

Tim Gardner (timg-tpi)
Changed in linux (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package linux - 2.6.30-10.11

---------------
linux (2.6.30-10.11) karmic; urgency=low

  [ Amit Kucheria ]

  * [Config] Comment splitconfig.pl and misc cleanup
  * [Config] Rename all configs to the new naming scheme
  * [Config] Splitconfig rework
  * [Config] Rename scripts/misc/oldconfig to kernelconfig
  * [Config] Fix build system for new config split
  * [Config] Run updateconfigs after the splitconfig rework

  [ Andy Whitcroft ]

  * Revert "SAUCE: Default to i915.modeset=0 if CONFIG_DRM_I915_KMS=y"
  * [Config] standardise CONFIG_STAGING=y
  * [Config] standardise CONFIG_RD_LZMA=y
  * [Config] CONFIG_PCI_IOV=y
  * [Config] CONFIG_PCI_STUB=m
  * [Config] merge kernel configs more agressively

  [ Colin Watson ]

  * [Config] Run kernel-wedge in $(builddir) rather than at the top level
  * [Config] Add support for including firmware in udebs
  * [Config] Ship bnx2 firmware in nic-modules udeb
    - LP: #384861

  [ Luke Yelavich ]

  * [Config] ports - Import of ports architectures into kernel packaging
    infrastructure
  * [Config] ports - Do not update ports kernel configurations by default
  * [Config] ports - Disable ABI checking for ports architectures
  * [Config] ports - Build drivers in ubuntu sub-directory on powerpc
  * [Config] ports - Add control.d/vars.* files for ports architectures
  * [Config] ports - Add ports architectures for linux-libc-dev
  * [Config] ports - Create powerpc specific message-modules and
    block-modules udebs
  * [Config] ports - Add configuration files for ports architectures

  [ Manoj Iyer ]

  * [Config] Enable CONFIG_BLK_DEV_AEC62XX=m for amd64 and i386
    - LP: #329864

  [ Michael Casadevall ]

  * [Config] ports - Fix compression of kernels

  [ Stefan Bader ]

  * [Upstream] mmc: prevent dangling block device from accessing stale
    queues
    - LP: #383668

  [ Tim Gardner ]

  * [Config] Recommend grub-pc in linux-image
    - LP: #385741
  * [Config] Implement i386 generic and generic-pae flavours
  * [Config] ports - Add control info after integrating ports arches
  * [Config] Removed auto-generated files from git
  * [Config] Added netxen_nic to nic-modules
    - LP: #389603

  [ Matt Zimmerman ]

  * Rename linux-doc-PKGVER to linux-doc and clean up its description
    - LP: #382115

 -- Tim Gardner <email address hidden> Mon, 15 Jun 2009 14:38:26 -0600

Changed in linux (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Stefan Bader (smb) wrote :

I tagged this upstream pending as the final upstream solution might/will be different.

> I plan to have a closer look at this first. I believe your solution isa workaround and doesn't solve the real issue. As
> such, I want to have one more go at finding and fixing the real problem before committing this. Your analysis should
> help a lot in that effort.
>
> Rgds
> -- Pierre Ossman

tags: added: upstream-pending
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.