05 Nov, 2011

1 commit

  • * 'for-3.2/drivers' of git://git.kernel.dk/linux-block: (30 commits)
    virtio-blk: use ida to allocate disk index
    hpsa: add small delay when using PCI Power Management to reset for kump
    cciss: add small delay when using PCI Power Management to reset for kump
    xen/blkback: Fix two races in the handling of barrier requests.
    xen/blkback: Check for proper operation.
    xen/blkback: Fix the inhibition to map pages when discarding sector ranges.
    xen/blkback: Report VBD_WSECT (wr_sect) properly.
    xen/blkback: Support 'feature-barrier' aka old-style BARRIER requests.
    xen-blkfront: plug device number leak in xlblk_init() error path
    xen-blkfront: If no barrier or flush is supported, use invalid operation.
    xen-blkback: use kzalloc() in favor of kmalloc()+memset()
    xen-blkback: fixed indentation and comments
    xen-blkfront: fix a deadlock while handling discard response
    xen-blkfront: Handle discard requests.
    xen-blkback: Implement discard requests ('feature-discard')
    xen-blkfront: add BLKIF_OP_DISCARD and discard request struct
    drivers/block/loop.c: remove unnecessary bdev argument from loop_clr_fd()
    drivers/block/loop.c: emit uevent on auto release
    drivers/block/cpqarray.c: use pci_dev->revision
    loop: always allow userspace partitions and optionally support automatic scanning
    ...

    Fic up trivial header file includsion conflict in drivers/block/loop.c

    Linus Torvalds
     

17 Oct, 2011

1 commit

  • Currently the loop device tries to call directly into write_begin/write_end
    instead of going through ->write if it can. This is a fairly nasty shortcut
    as write_begin and write_end are only callbacks for the generic write code
    and expect to be called with filesystem specific locks held.

    This code currently causes various issues for clustered filesystems as it
    doesn't take the required cluster locks, and it also causes issues for XFS
    as it doesn't properly lock against the swapext ioctl as called by the
    defragmentation tools. This in case causes data corruption if
    defragmentation hits a busy loop device in the wrong time window, as
    reported by RH QA.

    The reason why we have this shortcut is that it saves a data copy when
    doing a transformation on the loop device, which is the technical term
    for using cryptoloop (or an XOR transformation). Given that cryptoloop
    has been deprecated in favour of dm-crypt my opinion is that we should
    simply drop this shortcut instead of finding complicated ways to to
    introduce a formal interface for this shortcut.

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

    Christoph Hellwig
     

24 Aug, 2011

1 commit

  • Automatic partition scanning can be requested individually per loop
    device during its setup by setting LO_FLAGS_PARTSCAN. By default, no
    partition tables are scanned.

    Userspace can now always add and remove partitions from all loop
    devices, regardless if the in-kernel partition scanner is enabled or
    not.

    The needed partition minor numbers are allocated from the extended
    minors space, the main loop device numbers will continue to match the
    loop minors, regardless of the number of partitions used.

    # grep . /sys/class/block/loop1/loop/*
    /sys/block/loop1/loop/autoclear:0
    /sys/block/loop1/loop/backing_file:/home/kay/data/stuff/part.img
    /sys/block/loop1/loop/offset:0
    /sys/block/loop1/loop/partscan:1
    /sys/block/loop1/loop/sizelimit:0

    # ls -l /dev/loop*
    brw-rw---- 1 root disk 7, 0 Aug 14 20:22 /dev/loop0
    brw-rw---- 1 root disk 7, 1 Aug 14 20:23 /dev/loop1
    brw-rw---- 1 root disk 259, 0 Aug 14 20:23 /dev/loop1p1
    brw-rw---- 1 root disk 259, 1 Aug 14 20:23 /dev/loop1p2
    brw-rw---- 1 root disk 7, 99 Aug 14 20:23 /dev/loop99
    brw-rw---- 1 root disk 259, 2 Aug 14 20:23 /dev/loop99p1
    brw-rw---- 1 root disk 259, 3 Aug 14 20:23 /dev/loop99p2
    crw------T 1 root root 10, 237 Aug 14 20:22 /dev/loop-control

    Cc: Karel Zak
    Cc: Davidlohr Bueso
    Acked-By: Tejun Heo
    Signed-off-by: Kay Sievers
    Signed-off-by: Jens Axboe

    Kay Sievers
     

01 Aug, 2011

2 commits

  • Loop devices today have a fixed pre-allocated number of usually 8.
    The number can only be changed at module init time. To find a free
    device to use, /dev/loop%i needs to be scanned, and all devices need
    to be opened until a free one is possibly found.

    This adds a new /dev/loop-control device node, that allows to
    dynamically find or allocate a free device, and to add and remove loop
    devices from the running system:
    LOOP_CTL_ADD adds a specific device. Arg is the number
    of the device. It returns the device i or a negative
    error code.

    LOOP_CTL_REMOVE removes a specific device, Arg is the
    number the device. It returns the device i or a negative
    error code.

    LOOP_CTL_GET_FREE finds the next unbound device or allocates
    a new one. No arg is given. It returns the device i or a
    negative error code.

    The loop kernel module gets automatically loaded when
    /dev/loop-control is accessed the first time. The alias
    specified in the module, instructs udev to create this
    'dead' device node, even when the module is not loaded.

    Example:
    cfd = open("/dev/loop-control", O_RDWR);

    # add a new specific loop device
    err = ioctl(cfd, LOOP_CTL_ADD, devnr);

    # remove a specific loop device
    err = ioctl(cfd, LOOP_CTL_REMOVE, devnr);

    # find or allocate a free loop device to use
    devnr = ioctl(cfd, LOOP_CTL_GET_FREE);

    sprintf(loopname, "/dev/loop%i", devnr);
    ffd = open("backing-file", O_RDWR);
    lfd = open(loopname, O_RDWR);
    err = ioctl(lfd, LOOP_SET_FD, ffd);

    Cc: Tejun Heo
    Cc: Karel Zak
    Signed-off-by: Kay Sievers
    Signed-off-by: Jens Axboe

    Kay Sievers
     
  • Replace the linked list, that keeps track of allocated devices, with an
    idr index to allow a more efficient lookup of devices.

    Cc: Tejun Heo
    Signed-off-by: Kay Sievers
    Signed-off-by: Jens Axboe

    Kay Sievers
     

28 Apr, 2009

1 commit


01 Apr, 2009

1 commit

  • Add the ability to 'resize' the loop device on the fly.

    One practical application is a loop file with XFS filesystem, already
    mounted: You can easily enlarge the file (append some bytes) and then call
    ioctl(fd, LOOP_SET_CAPACITY, new); The loop driver will learn about the
    new size and you can use xfs_growfs later on, which will allow you to use
    full capacity of the loop file without the need to unmount.

    Test app:

    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include

    #define _GNU_SOURCE
    #include

    char *me;

    void usage(FILE *f)
    {
    fprintf(f, "%s [options] loop_dev [backend_file]\n"
    "-s, --set new_size_in_bytes\n"
    "\twhen backend_file is given, "
    "it will be expanded too while keeping the original contents\n",
    me);
    }

    struct option opts[] = {
    {
    .name = "set",
    .has_arg = 1,
    .flag = NULL,
    .val = 's'
    },
    {
    .name = "help",
    .has_arg = 0,
    .flag = NULL,
    .val = 'h'
    }
    };

    void err_size(char *name, __u64 old)
    {
    fprintf(stderr, "size must be larger than current %s (%llu)\n",
    name, old);
    }

    int main(int argc, char *argv[])
    {
    int fd, err, c, i, bfd;
    ssize_t ssz;
    size_t sz;
    __u64 old, new, append;
    char a[BUFSIZ];
    struct stat st;
    FILE *out;
    char *backend, *dev;

    err = EINVAL;
    out = stderr;
    me = argv[0];
    new = 0;
    while ((c = getopt_long(argc, argv, "s:h", opts, &i)) != -1) {
    switch (c) {
    case 's':
    errno = 0;
    new = strtoull(optarg, NULL, 0);
    if (errno) {
    err = errno;
    perror(argv[i]);
    goto out;
    }
    break;

    case 'h':
    err = 0;
    out = stdout;
    goto err;

    default:
    perror(argv[i]);
    goto err;
    }
    }

    if (optind < argc)
    dev = argv[optind++];
    else
    goto err;

    fd = open(dev, O_RDONLY);
    if (fd < 0) {
    err = errno;
    perror(dev);
    goto out;
    }

    err = ioctl(fd, BLKGETSIZE64, &old);
    if (err) {
    err = errno;
    perror("ioctl BLKGETSIZE64");
    goto out;
    }

    if (!new) {
    printf("%llu\n", old);
    goto out;
    }

    if (new < old) {
    err = EINVAL;
    err_size(dev, old);
    goto out;
    }

    if (optind < argc) {
    backend = argv[optind++];
    bfd = open(backend, O_WRONLY|O_APPEND);
    if (bfd < 0) {
    err = errno;
    perror(backend);
    goto out;
    }
    err = fstat(bfd, &st);
    if (err) {
    err = errno;
    perror(backend);
    goto out;
    }
    if (new < st.st_size) {
    err = EINVAL;
    err_size(backend, st.st_size);
    goto out;
    }
    append = new - st.st_size;
    sz = sizeof(a);
    while (append > 0) {
    if (append < sz)
    sz = append;
    ssz = write(bfd, a, sz);
    if (ssz != sz) {
    err = errno;
    perror(backend);
    goto out;
    }
    append -= sz;
    }
    err = fsync(bfd);
    if (err) {
    err = errno;
    perror(backend);
    goto out;
    }
    }

    err = ioctl(fd, LOOP_SET_CAPACITY, new);
    if (err) {
    err = errno;
    perror("ioctl LOOP_SET_CAPACITY");
    }
    goto out;

    err:
    usage(out);
    out:
    return err;
    }

    Signed-off-by: J. R. Okajima
    Signed-off-by: Tomas Matejicek
    Cc:
    Cc: Karel Zak
    Cc: Jens Axboe
    Cc: Al Viro
    Cc: Christoph Hellwig
    Cc: Akinobu Mita
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    J. R. Okajima
     

16 Jan, 2009

1 commit


07 Feb, 2008

1 commit

  • This allows a flag to be set on loop devices so that when they are
    closed for the last time, they'll self-destruct.

    In general, so that we can automatically allocate loop devices (as with
    losetup -f) and have them disappear when we're done with them.

    In particular, right now, so that we can stop relying on the hackish
    special-case in umount(8) which kills off loop devices which were set up by
    'mount -oloop'. That means we can stop putting crap in /etc/mtab which
    doesn't belong there, which means it can be a symlink to /proc/mounts, which
    means yet another writable file on the root filesystem is eliminated and the
    'stateless' folks get happier... and OLPC trac #356 can be closed.

    The mount(8) side of that is at
    http://marc.info/?l=util-linux-ng&m=119362955431694&w=2

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: David Woodhouse
    Cc: Bernardo Innocenti
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Woodhouse
     

25 Jul, 2007

1 commit

  • include/linux/loop.h:66: error: expected specifier-qualifier-list before 'request_queue_t'

    Cc: Sebastian Siewior
    Cc: Jens Axboe
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     

09 May, 2007

1 commit

  • Remove artificial maximum 256 loop device that can be created due to a
    legacy device number limit. Searching through lkml archive, there are
    several instances where users complained about the artificial limit that
    the loop driver impose. There is no reason to have such limit.

    This patch rid the limit entirely and make loop device and associated block
    queue instantiation on demand. With on-demand instantiation, it also gives
    the benefit of not wasting memory if these devices are not in use (compare
    to current implementation that always create 8 loop devices), a net
    improvement in both areas. This version is both tested with creation of
    large number of loop devices and is compatible with existing losetup/mount
    user land tools.

    There are a number of people who worked on this and provided valuable
    suggestions, in no particular order, by:

    Jens Axboe
    Jan Engelhardt
    Christoph Hellwig
    Thomas M

    Signed-off-by: Ken Chen
    Cc: Jan Engelhardt
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ken Chen
     

30 Sep, 2006

1 commit

  • Convert loop.c from the deprecated kernel_thread to kthread. This patch
    simplifies the code quite a bit and passes similar testing to the previous
    submission on both emulated x86 and s390.

    Changes since last submission:
    switched to using a rather simple loop based on
    wait_event_interruptible.

    Signed-off-by: Serge E. Hallyn
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Serge E. Hallyn
     

27 Jun, 2006

1 commit

  • This reverts commit c7b2eff059fcc2d1b7085ee3d84b79fd657a537b.

    Hugh Dickins explains:

    "It seems too little tested: "losetup -d /dev/loop0" fails with
    EINVAL because nothing sets lo_thread; but even when you patch
    loop_thread() to set lo->lo_thread = current, it can't survive
    more than a few dozen iterations of the loop below (with a tmpfs
    mounted on /tst):

    j=0
    cp /dev/zero /tst
    while :
    do
    let j=j+1
    echo "Doing pass $j"
    losetup /dev/loop0 /tst/zero
    mkfs -t ext2 -b 1024 /dev/loop0 >/dev/null 2>&1
    mount -t ext2 /dev/loop0 /mnt
    umount /mnt
    losetup -d /dev/loop0
    done

    it collapses with failed ioctl then BUG_ON(!bio).

    I think the original lo_done completion was more subtle and safe
    than the kthread conversion has allowed for."

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

26 Jun, 2006

1 commit


23 Mar, 2006

1 commit

  • Semaphore to mutex conversion.

    The conversion was generated via scripts, and the result was validated
    automatically via a script as well.

    Signed-off-by: Ingo Molnar
    Cc: Jens Axboe
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ingo Molnar
     

10 Jan, 2006

1 commit


28 Oct, 2005

1 commit


24 Jun, 2005

1 commit

  • Looks like locking can be optimised quite a lot. Increase lock widths
    slightly so lo_lock is taken fewer times per request. Also it was quite
    trivial to cover lo_pending with that lock, and remove the atomic
    requirement. This also makes memory ordering explicitly correct, which is
    nice (not that I particularly saw any mem ordering bugs).

    Test was reading 4 250MB files in parallel on ext2-on-tmpfs filesystem (1K
    block size, 4K page size). System is 2 socket Xeon with HT (4 thread).

    intel:/home/npiggin# umount /dev/loop0 ; mount /dev/loop0 /mnt/loop ; /usr/bin/time ./mtloop.sh

    Before:
    0.24user 5.51system 0:02.84elapsed 202%CPU (0avgtext+0avgdata 0maxresident)k
    0.19user 5.52system 0:02.88elapsed 198%CPU (0avgtext+0avgdata 0maxresident)k
    0.19user 5.57system 0:02.89elapsed 198%CPU (0avgtext+0avgdata 0maxresident)k
    0.22user 5.51system 0:02.90elapsed 197%CPU (0avgtext+0avgdata 0maxresident)k
    0.19user 5.44system 0:02.91elapsed 193%CPU (0avgtext+0avgdata 0maxresident)k

    After:
    0.07user 2.34system 0:01.68elapsed 143%CPU (0avgtext+0avgdata 0maxresident)k
    0.06user 2.37system 0:01.68elapsed 144%CPU (0avgtext+0avgdata 0maxresident)k
    0.06user 2.39system 0:01.68elapsed 145%CPU (0avgtext+0avgdata 0maxresident)k
    0.06user 2.36system 0:01.68elapsed 144%CPU (0avgtext+0avgdata 0maxresident)k
    0.06user 2.42system 0:01.68elapsed 147%CPU (0avgtext+0avgdata 0maxresident)k

    Signed-off-by: Nick Piggin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nick Piggin
     

17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds