07 Feb, 2010

1 commit

  • Thanks Thomas and Christoph for testing and review.
    I removed 'smp_wmb()' before up_write from the previous patch,
    since up_write() should have necessary ordering constraints.
    (I.e. the change of s_frozen is visible to others after up_write)
    I'm quite sure the change is harmless but if you are uncomfortable
    with Tested-by/Reviewed-by on the modified patch, please remove them.

    If MS_RDONLY, freeze_bdev should just up_write(s_umount) instead of
    deactivate_locked_super().
    Also, keep sb->s_frozen consistent so that remount can check the frozen state.

    Otherwise a crash reported here can happen:
    http://lkml.org/lkml/2010/1/16/37
    http://lkml.org/lkml/2010/1/28/53

    This patch should be applied for 2.6.32 stable series, too.

    Reviewed-by: Christoph Hellwig
    Tested-by: Thomas Backlund
    Signed-off-by: Jun'ichi Nomura
    Cc: stable@kernel.org
    Signed-off-by: Al Viro

    Jun'ichi Nomura
     

04 Nov, 2009

1 commit


29 Oct, 2009

1 commit

  • Currently there is no barrier support in the block device code. That
    means we cannot guarantee any sort of data integerity when using the
    block device node with dis kwrite caches enabled. Using the raw block
    device node is a typical use case for virtualization (and I assume
    databases, too). This patch changes block_fsync to issue a cache flush
    and thus make fsync on block device nodes actually useful.

    Note that in mainline we would also need to add such code to the
    ->aio_write method for O_SYNC handling, but assuming that Jan's patch
    series for the O_SYNC rewrite goes in it will also call into ->fsync
    for 2.6.32.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

26 Oct, 2009

1 commit

  • commit 0762b8bde9729f10f8e6249809660ff2ec3ad735
    (from 14 months ago) introduced a use-after-free bug which has just
    recently started manifesting in my md testing.
    I tried git bisect to find out what caused the bug to start
    manifesting, and it could have been the recent change to
    blk_unregister_queue (48c0d4d4c04) but the results were inconclusive.

    This patch certainly fixes my symptoms and looks correct as the two
    calls are now in the same order as elsewhere in that function.

    Signed-off-by: NeilBrown
    Acked-by: Tejun Heo
    Signed-off-by: Jens Axboe

    Neil Brown
     

24 Sep, 2009

2 commits

  • Currently we held s_umount while a filesystem is frozen, despite that we
    might return to userspace and unlock it from a different process. Instead
    grab an active reference to keep the file system busy and add an explicit
    check for frozen filesystems in remount and reject the remount instead
    of blocking on s_umount.

    Add a new get_active_super helper to super.c for use by freeze_bdev that
    grabs an active reference to a superblock from a given block device.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     
  • Now that we have the freeze count there is not much reason for bd_mount_sem
    anymore. The actual freeze/thaw operations are serialized using the
    bd_fsfreeze_mutex, and the only other place we take bd_mount_sem is
    get_sb_bdev which tries to prevent mounting a filesystem while the block
    device is frozen. Instead of add a check for bd_fsfreeze_count and
    return -EBUSY if a filesystem is frozen. While that is a change in user
    visible behaviour a failing mount is much better for this case rather
    than having the mount process stuck uninterruptible for a long time.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     

22 Sep, 2009

1 commit


16 Sep, 2009

1 commit

  • It has been unused since it was introduced in:

    commit 520808bf20e90fdbdb320264ba7dd5cf9d47dcac
    Author: Andrew Morton
    Date: Fri May 21 00:46:17 2004 -0700

    [PATCH] block device layer: separate backing_dev_info infrastructure

    So lets just kill it.

    Acked-by: Jan Kara
    Signed-off-by: Jens Axboe

    Jens Axboe
     

14 Sep, 2009

1 commit

  • generic_file_aio_write_nolock() is now used only by block devices and raw
    character device. Filesystems should use __generic_file_aio_write() in case
    generic_file_aio_write() doesn't suit them. So rename the function to
    blkdev_aio_write() and move it to fs/blockdev.c.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Christoph Hellwig
     

30 Jul, 2009

1 commit

  • Create bdgrab(). This function copies an existing reference to a
    block_device. It is safe to call from any context.

    Hibernation code wishes to copy a reference to the active swap device.
    Right now it calls bdget() under a spinlock, but this is wrong because
    bdget() can sleep. It doesn't need a full bdget() because we already
    hold a reference to active swap devices (and the spinlock protects
    against swapoff).

    Fixes http://bugzilla.kernel.org/show_bug.cgi?id=13827

    Signed-off-by: Alan Jenkins
    Signed-off-by: Rafael J. Wysocki

    Alan Jenkins
     

12 Jun, 2009

5 commits

  • Rename the function so that it better describe what it really does. Also
    remove the unnecessary include of buffer_head.h.

    Signed-off-by: Jan Kara
    Signed-off-by: Al Viro

    Jan Kara
     
  • It is unnecessarily fragile to have two places (fsync_super() and do_sync())
    doing data integrity sync of the filesystem. Alter __fsync_super() to
    accommodate needs of both callers and use it. So after this patch
    __fsync_super() is the only place where we gather all the calls needed to
    properly send all data on a filesystem to disk.

    Nice bonus is that we get a complete livelock avoidance and write_supers()
    is now only used for periodic writeback of superblocks.

    sync_blockdevs() introduced a couple of patches ago is gone now.

    [build fixes folded]

    Signed-off-by: Jan Kara
    Signed-off-by: Al Viro

    Jan Kara
     
  • __fsync_super() does the same thing as fsync_super(). So change the only
    caller to use fsync_super() and make __fsync_super() static. This removes
    unnecessarily duplicated call to sync_blockdev() and prepares ground
    for the changes to __fsync_super() in the following patches.

    Signed-off-by: Jan Kara
    Signed-off-by: Al Viro

    Jan Kara
     
  • * 'for-linus' of git://linux-arm.org/linux-2.6:
    kmemleak: Add the corresponding MAINTAINERS entry
    kmemleak: Simple testing module for kmemleak
    kmemleak: Enable the building of the memory leak detector
    kmemleak: Remove some of the kmemleak false positives
    kmemleak: Add modules support
    kmemleak: Add kmemleak_alloc callback from alloc_large_system_hash
    kmemleak: Add the vmalloc memory allocation/freeing hooks
    kmemleak: Add the slub memory allocation/freeing hooks
    kmemleak: Add the slob memory allocation/freeing hooks
    kmemleak: Add the slab memory allocation/freeing hooks
    kmemleak: Add documentation on the memory leak detector
    kmemleak: Add the base support

    Manual conflict resolution (with the slab/earlyboot changes) in:
    drivers/char/vt.c
    init/main.c
    mm/slab.c

    Linus Torvalds
     
  • There are allocations for which the main pointer cannot be found but
    they are not memory leaks. This patch fixes some of them. For more
    information on false positives, see Documentation/kmemleak.txt.

    Signed-off-by: Catalin Marinas

    Catalin Marinas
     

05 Jun, 2009

1 commit

  • This reverts commit db2dbb12dc47a50c7a4c5678f526014063e486f6.

    It apparently causes problems with partition table read-ahead
    on archs with large page sizes. Until that problem is diagnosed
    further, just drop the readpages support on block devices.

    Signed-off-by: Jens Axboe

    Jens Axboe
     

23 May, 2009

1 commit

  • Until now we have had a 1:1 mapping between storage device physical
    block size and the logical block sized used when addressing the device.
    With SATA 4KB drives coming out that will no longer be the case. The
    sector size will be 4KB but the logical block size will remain
    512-bytes. Hence we need to distinguish between the physical block size
    and the logical ditto.

    This patch renames hardsect_size to logical_block_size.

    Signed-off-by: Martin K. Petersen
    Signed-off-by: Jens Axboe

    Martin K. Petersen
     

28 Apr, 2009

1 commit


01 Apr, 2009

1 commit


28 Mar, 2009

1 commit


10 Jan, 2009

1 commit

  • The ioctls for the generic freeze feature are below.
    o Freeze the filesystem
    int ioctl(int fd, int FIFREEZE, arg)
    fd: The file descriptor of the mountpoint
    FIFREEZE: request code for the freeze
    arg: Ignored
    Return value: 0 if the operation succeeds. Otherwise, -1

    o Unfreeze the filesystem
    int ioctl(int fd, int FITHAW, arg)
    fd: The file descriptor of the mountpoint
    FITHAW: request code for unfreeze
    arg: Ignored
    Return value: 0 if the operation succeeds. Otherwise, -1
    Error number: If the filesystem has already been unfrozen,
    errno is set to EINVAL.

    [akpm@linux-foundation.org: fix CONFIG_BLOCK=n]
    Signed-off-by: Takashi Sato
    Signed-off-by: Masayuki Hamaguchi
    Cc:
    Cc:
    Cc: Christoph Hellwig
    Cc: Dave Kleikamp
    Cc: Dave Chinner
    Cc: Alasdair G Kergon
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Takashi Sato
     

09 Jan, 2009

2 commits

  • * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (57 commits)
    jbd2: Fix oops in jbd2_journal_init_inode() on corrupted fs
    ext4: Remove "extents" mount option
    block: Add Kconfig help which notes that ext4 needs CONFIG_LBD
    ext4: Make printk's consistently prefixed with "EXT4-fs: "
    ext4: Add sanity checks for the superblock before mounting the filesystem
    ext4: Add mount option to set kjournald's I/O priority
    jbd2: Submit writes to the journal using WRITE_SYNC
    jbd2: Add pid and journal device name to the "kjournald2 starting" message
    ext4: Add markers for better debuggability
    ext4: Remove code to create the journal inode
    ext4: provide function to release metadata pages under memory pressure
    ext3: provide function to release metadata pages under memory pressure
    add releasepage hooks to block devices which can be used by file systems
    ext4: Fix s_dirty_blocks_counter if block allocation failed with nodelalloc
    ext4: Init the complete page while building buddy cache
    ext4: Don't allow new groups to be added during block allocation
    ext4: mark the blocks/inode bitmap beyond end of group as used
    ext4: Use new buffer_head flag to check uninit group bitmaps initialization
    ext4: Fix the race between read_inode_bitmap() and ext4_new_inode()
    ext4: code cleanup
    ...

    Linus Torvalds
     
  • Currently md devices, once created, never disappear until the module
    is unloaded. This is essentially because the gendisk holds a
    reference to the mddev, and the mddev holds a reference to the
    gendisk, this a circular reference.

    If we drop the reference from mddev to gendisk, then we need to ensure
    that the mddev is destroyed when the gendisk is destroyed. However it
    is not possible to hook into the gendisk destruction process to enable
    this.

    So we drop the reference from the gendisk to the mddev and destroy the
    gendisk when the mddev gets destroyed. However this has a
    complication.
    Between the call
    __blkdev_get->get_gendisk->kobj_lookup->md_probe
    and the call
    __blkdev_get->md_open

    there is no obvious way to hold a reference on the mddev any more, so
    unless something is done, it will disappear and gendisk will be
    destroyed prematurely.

    Also, once we decide to destroy the mddev, there will be an unlockable
    moment before the gendisk is unlinked (blk_unregister_region) during
    which a new reference to the gendisk can be created. We need to
    ensure that this reference can not be used. i.e. the ->open must
    fail.

    So:
    1/ in md_probe we set a flag in the mddev (hold_active) which
    indicates that the array should be treated as active, even
    though there are no references, and no appearance of activity.
    This is cleared by md_release when the device is closed if it
    is no longer needed.
    This ensures that the gendisk will survive between md_probe and
    md_open.

    2/ In md_open we check if the mddev we expect to open matches
    the gendisk that we did open.
    If there is a mismatch we return -ERESTARTSYS and modify
    __blkdev_get to retry from the top in that case.
    In the -ERESTARTSYS sys case we make sure to wait until
    the old gendisk (that we succeeded in opening) is really gone so
    we loop at most once.

    Some udev configurations will always open an md device when it first
    appears. If we allow an md device that was just created by an open
    to disappear on an immediate close, then this can race with such udev
    configurations and result in an infinite loop the device being opened
    and closed, then re-open due to the 'ADD' even from the first open,
    and then close and so on.
    So we make sure an md device, once created by an open, remains active
    at least until some md 'ioctl' has been made on it. This means that
    all normal usage of md devices will allow them to disappear promptly
    when not needed, but the worst that an incorrect usage will do it
    cause an inactive md device to be left in existence (it can easily be
    removed).

    As an array can be stopped by writing to a sysfs attribute
    echo clear > /sys/block/mdXXX/md/array_state
    we need to use scheduled work for deleting the gendisk and other
    kobjects. This allows us to wait for any pending gendisk deletion to
    complete by simply calling flush_scheduled_work().

    Signed-off-by: NeilBrown

    NeilBrown
     

07 Jan, 2009

1 commit

  • Fix function parameter name in kernel-doc:

    Warning(linux-2.6.28-git5//fs/block_dev.c:1272): No description found for parameter 'pathname'
    Warning(linux-2.6.28-git5//fs/block_dev.c:1272): Excess function parameter 'path' description in 'lookup_bdev'

    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

03 Jan, 2009

1 commit


01 Jan, 2009

1 commit

  • - iget5_locked in bdget really needs blockdev_superblock, instead of
    bd_mnt, so bd_mnt could be just a local variable;

    - blockdev_superblock really needs __read_mostly, while local var bd_mnt
    not;

    - make use of sb_is_blkdev_sb in bd_forget, instead of direct reference
    to blockdev_superblock.

    Signed-off-by: Denis ChengRq
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Al Viro

    Denis ChengRq
     

04 Dec, 2008

2 commits


06 Nov, 2008

1 commit

  • Commit 0762b8bde9729f10f8e6249809660ff2ec3ad735 moved disk_get_part()
    in front of recursive get on the whole disk, which caused removable
    devices to try disk_get_part() before rescanning after a new media is
    inserted, which might fail legit open attempts or give the old
    partition.

    This patch fixes the problem by moving disk_get_part() after
    __blkdev_get() on the whole disk.

    This problem was spotted by Borislav Petkov.

    Signed-off-by: Tejun Heo
    Tested-by: Borislav Petkov
    Signed-off-by: Jens Axboe

    Tejun Heo
     

24 Oct, 2008

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/viro/bdev: (66 commits)
    [PATCH] kill the rest of struct file propagation in block ioctls
    [PATCH] get rid of struct file use in blkdev_ioctl() BLKBSZSET
    [PATCH] get rid of blkdev_locked_ioctl()
    [PATCH] get rid of blkdev_driver_ioctl()
    [PATCH] sanitize blkdev_get() and friends
    [PATCH] remember mode of reiserfs journal
    [PATCH] propagate mode through swsusp_close()
    [PATCH] propagate mode through open_bdev_excl/close_bdev_excl
    [PATCH] pass fmode_t to blkdev_put()
    [PATCH] kill the unused bsize on the send side of /dev/loop
    [PATCH] trim file propagation in block/compat_ioctl.c
    [PATCH] end of methods switch: remove the old ones
    [PATCH] switch sr
    [PATCH] switch sd
    [PATCH] switch ide-scsi
    [PATCH] switch tape_block
    [PATCH] switch dcssblk
    [PATCH] switch dasd
    [PATCH] switch mtd_blkdevs
    [PATCH] switch mmc
    ...

    Linus Torvalds
     

23 Oct, 2008

1 commit


21 Oct, 2008

8 commits


17 Oct, 2008

1 commit

  • Fix block kernel-doc warnings:

    Warning(linux-2.6.27-git4//fs/block_dev.c:1272): No description found for parameter 'path'
    Warning(linux-2.6.27-git4//block/blk-core.c:1021): No description found for parameter 'cpu'
    Warning(linux-2.6.27-git4//block/blk-core.c:1021): No description found for parameter 'part'
    Warning(/var/linsrc/linux-2.6.27-git4//block/genhd.c:544): No description found for parameter 'partno'

    Signed-off-by: Randy Dunlap
    Signed-off-by: Jens Axboe

    Randy Dunlap