1. 03 4月, 2009 3 次提交
  2. 02 4月, 2009 3 次提交
  3. 01 4月, 2009 1 次提交
    • J
      loop: add ioctl to resize a loop device · 53d66608
      J. R. Okajima 提交于
      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 <linux/fs.h>
      #include <linux/loop.h>
      #include <sys/ioctl.h>
      #include <sys/stat.h>
      #include <sys/types.h>
      #include <assert.h>
      #include <errno.h>
      #include <fcntl.h>
      #include <stdio.h>
      #include <stdlib.h>
      #include <unistd.h>
      
      #define _GNU_SOURCE
      #include <getopt.h>
      
      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: NJ. R. Okajima <hooanon05@yahoo.co.jp>
      Signed-off-by: NTomas Matejicek <tomas@slax.org>
      Cc: <util-linux-ng@vger.kernel.org>
      Cc: Karel Zak <kzak@redhat.com>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Akinobu Mita <akinobu.mita@gmail.com>
      Cc: <linux-api@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      53d66608
  4. 31 3月, 2009 1 次提交
    • A
      proc 2/2: remove struct proc_dir_entry::owner · 99b76233
      Alexey Dobriyan 提交于
      Setting ->owner as done currently (pde->owner = THIS_MODULE) is racy
      as correctly noted at bug #12454. Someone can lookup entry with NULL
      ->owner, thus not pinning enything, and release it later resulting
      in module refcount underflow.
      
      We can keep ->owner and supply it at registration time like ->proc_fops
      and ->data.
      
      But this leaves ->owner as easy-manipulative field (just one C assignment)
      and somebody will forget to unpin previous/pin current module when
      switching ->owner. ->proc_fops is declared as "const" which should give
      some thoughts.
      
      ->read_proc/->write_proc were just fixed to not require ->owner for
      protection.
      
      rmmod'ed directories will be empty and return "." and ".." -- no harm.
      And directories with tricky enough readdir and lookup shouldn't be modular.
      We definitely don't want such modular code.
      
      Removing ->owner will also make PDE smaller.
      
      So, let's nuke it.
      
      Kudos to Jeff Layton for reminding about this, let's say, oversight.
      
      http://bugzilla.kernel.org/show_bug.cgi?id=12454Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      99b76233
  5. 27 3月, 2009 1 次提交
  6. 26 3月, 2009 1 次提交
    • N
      loop: fix circular locking in loop_clr_fd() · f028f3b2
      Nikanth Karthikesan 提交于
      With CONFIG_PROVE_LOCKING enabled
      
      $ losetup /dev/loop0 file
      $ losetup -o 32256 /dev/loop1 /dev/loop0
      
      $ losetup -d /dev/loop1
      $ losetup -d /dev/loop0
      
      triggers a [ INFO: possible circular locking dependency detected ]
      
      I think this warning is a false positive.
      
      Open/close on a loop device acquires bd_mutex of the device before
      acquiring lo_ctl_mutex of the same device. For ioctl(LOOP_CLR_FD) after
      acquiring lo_ctl_mutex, fput on the backing_file might acquire the bd_mutex of
      a device, if backing file is a device and this is the last reference to the
      file being dropped . But it is guaranteed that it is impossible to have a
      circular list of backing devices.(say loop2->loop1->loop0->loop2 is not
      possible), which guarantees that this can never deadlock.
      
      So this warning should be suppressed. It is very difficult to annotate lockdep
      not to warn here in the correct way. A simple way to silence lockdep could be
      to mark the lo_ctl_mutex in ioctl to be a sub class, but this might mask some
      other real bugs.
      
      @@ -1164,7 +1164,7 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
       	struct loop_device *lo = bdev->bd_disk->private_data;
       	int err;
      
      -	mutex_lock(&lo->lo_ctl_mutex);
      +	mutex_lock_nested(&lo->lo_ctl_mutex, 1);
       	switch (cmd) {
       	case LOOP_SET_FD:
       		err = loop_set_fd(lo, mode, bdev, arg);
      
      Or actually marking the bd_mutex after lo_ctl_mutex as a sub class could be
      a better solution.
      
      Luckily it is easy to avoid calling fput on backing file with lo_ctl_mutex
      held, so no lockdep annotation is required.
      
      If you do not like the special handling of the lo_ctl_mutex just for the
      LOOP_CLR_FD ioctl in lo_ioctl(), the mutex handling could be moved inside
      each of the individual ioctl handlers and I could send you another patch.
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      f028f3b2
  7. 25 3月, 2009 3 次提交
    • E
      platform: make better use of to_platform_{device,driver}() macros · 71b3e0c1
      Eric Miao 提交于
      This helps the code look more consistent and cleaner.
      Signed-off-by: NEric Miao <eric.miao@marvell.com>
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      71b3e0c1
    • A
      usb-storage: prepare for subdriver separation · e6e244b6
      Alan Stern 提交于
      This patch (as1206) is the first step in converting usb-storage's
      subdrivers into separate modules.  It makes the following large-scale
      changes:
      
      	Remove a bunch of unnecessary #ifdef's from usb_usual.h.
      	Not truly necessary, but it does clean things up.
      
      	Move the USB device-ID table (which is duplicated between
      	libusual and usb-storage) into its own source file,
      	usual-tables.c, and arrange for this to be linked with
      	either libusual or usb-storage according to whether
      	USB_LIBUSUAL is configured.
      
      	Add to usual-tables.c a new usb_usual_ignore_device()
      	function to detect whether a particular device needs to be
      	managed by a subdriver and not by the standard handlers
      	in usb-storage.
      
      	Export a whole bunch of functions in usb-storage, renaming
      	some of them because their names don't already begin with
      	"usb_stor_".  These functions will be needed by the new
      	subdriver modules.
      
      	Split usb-storage's probe routine into two functions.
      	The subdrivers will call the probe1 routine, then fill in
      	their transport and protocol settings, and then call the
      	probe2 routine.
      
      	Take the default cases and error checking out of
      	get_transport() and get_protocol(), which run during
      	probe1, and instead put a check for invalid transport
      	or protocol values into the probe2 function.
      
      	Add a new probe routine to be used for standard devices,
      	i.e., those that don't need a subdriver.  This new routine
      	checks whether the device should be ignored (because it
      	should be handled by ub or by a subdriver), and if not,
      	calls the probe1 and probe2 functions.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e6e244b6
    • J
      USB: ub: use USB API functions rather than constants · db5e6df1
      Julia Lawall 提交于
      This set of patches introduces calls to the following set of functions:
      
      usb_endpoint_dir_in(epd)
      usb_endpoint_dir_out(epd)
      usb_endpoint_is_bulk_in(epd)
      usb_endpoint_is_bulk_out(epd)
      usb_endpoint_is_int_in(epd)
      usb_endpoint_is_int_out(epd)
      usb_endpoint_num(epd)
      usb_endpoint_type(epd)
      usb_endpoint_xfer_bulk(epd)
      usb_endpoint_xfer_control(epd)
      usb_endpoint_xfer_int(epd)
      usb_endpoint_xfer_isoc(epd)
      
      In some cases, introducing one of these functions is not possible, and it
      just replaces an explicit integer value by one of the following constants:
      
      USB_ENDPOINT_XFER_BULK
      USB_ENDPOINT_XFER_CONTROL
      USB_ENDPOINT_XFER_INT
      USB_ENDPOINT_XFER_ISOC
      
      An extract of the semantic patch that makes these changes is as follows:
      (http://www.emn.fr/x-info/coccinelle/)
      
      // <smpl>
      @r1@ struct usb_endpoint_descriptor *epd; @@
      
      - ((epd->bmAttributes & \(USB_ENDPOINT_XFERTYPE_MASK\|3\)) ==
      - \(USB_ENDPOINT_XFER_CONTROL\|0\))
      + usb_endpoint_xfer_control(epd)
      
      @r5@ struct usb_endpoint_descriptor *epd; @@
      
      - ((epd->bEndpointAddress & \(USB_ENDPOINT_DIR_MASK\|0x80\)) ==
      -  \(USB_DIR_IN\|0x80\))
      + usb_endpoint_dir_in(epd)
      
      @inc@
      @@
      
      #include <linux/usb.h>
      
      @depends on !inc && (r1||r5)@
      @@
      
      + #include <linux/usb.h>
        #include <linux/usb/...>
      // </smpl>
      Signed-off-by: NJulia Lawall <julia@diku.dk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      db5e6df1
  8. 24 3月, 2009 3 次提交
  9. 15 3月, 2009 1 次提交
  10. 13 3月, 2009 1 次提交
  11. 10 3月, 2009 1 次提交
  12. 05 3月, 2009 3 次提交
  13. 04 3月, 2009 1 次提交
  14. 26 2月, 2009 2 次提交
    • J
      xen/blkfront: use blk_rq_map_sg to generate ring entries · 9e973e64
      Jens Axboe 提交于
      On occasion, the request will apparently have more segments than we
      fit into the ring. Jens says:
      
      > The second problem is that the block layer then appears to create one
      > too many segments, but from the dump it has rq->nr_phys_segments ==
      > BLKIF_MAX_SEGMENTS_PER_REQUEST. I suspect the latter is due to
      > xen-blkfront not handling the merging on its own. It should check that
      > the new page doesn't form part of the previous page. The
      > rq_for_each_segment() iterates all single bits in the request, not dma
      > segments. The "easiest" way to do this is to call blk_rq_map_sg() and
      > then iterate the mapped sg list. That will give you what you are
      > looking for.
      
      > Here's a test patch, compiles but otherwise untested. I spent more
      > time figuring out how to enable XEN than to code it up, so YMMV!
      > Probably the sg list wants to be put inside the ring and only
      > initialized on allocation, then you can get rid of the sg on stack and
      > sg_init_table() loop call in the function. I'll leave that, and the
      > testing, to you.
      
      [Moved sg array into info structure, and initialize once. -J]
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      Signed-off-by: NJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
      9e973e64
    • J
      cciss: shorten 30s timeout on controller reset · 5e4c91c8
      Jens Axboe 提交于
      If reset_devices is set for kexec, then cciss will delay 30 seconds
      since the old 5i controller _may_ need that long to recover. Replace
      the long sleep with incremental sleep and tests to reduce the 30 seconds
      to worst case for 5i, so that other controllers will proceed quickly.
      Reviewed-by: NMike Miller <mike.miller@hp.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      5e4c91c8
  15. 23 2月, 2009 1 次提交
  16. 19 2月, 2009 2 次提交
  17. 18 2月, 2009 2 次提交
  18. 12 2月, 2009 1 次提交
    • P
      nbd: fix I/O hang on disconnected nbds · 4d48a542
      Paul Clements 提交于
      Fix a problem that causes I/O to a disconnected (or partially initialized)
      nbd device to hang indefinitely.  To reproduce:
      
      # ioctl NBD_SET_SIZE_BLOCKS /dev/nbd23 514048
      # dd if=/dev/nbd23 of=/dev/null bs=4096 count=1
      
      ...hangs...
      
      This can also occur when an nbd device loses its nbd-client/server
      connection.  Although we clear the queue of any outstanding I/Os after the
      client/server connection fails, any additional I/Os that get queued later
      will hang.
      
      This bug may also be the problem reported in this bug report:
      http://bugzilla.kernel.org/show_bug.cgi?id=12277
      
      Testing would need to be performed to determine if the two issues are the
      same.
      
      This problem was introduced by the new request handling thread code ("NBD:
      allow nbd to be used locally", 3/2008), which entered into mainline around
      2.6.25.
      
      The fix, which is fairly simple, is to restore the check for lo->sock
      being NULL in do_nbd_request.  This causes I/O to an uninitialized nbd to
      immediately fail with an I/O error, as it did prior to the introduction of
      this bug.
      Signed-off-by: NPaul Clements <paul.clements@steeleye.com>
      Reported-by: NJon Nelson <jnelson-kernel-bugzilla@jamponi.net>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Cc: <stable@kernel.org>		[2.6.26.x, 2.6.27.x, 2.6.28.x]
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4d48a542
  19. 16 1月, 2009 2 次提交
  20. 13 1月, 2009 1 次提交
    • A
      m68k: amiflop - Get rid of sleep_on calls · 6d0be946
      Andreas Bombe 提交于
      Apart from sleep_on() calls that could be easily converted to
      wait_event() and completion calls amiflop also used a flag in ms_delay()
      and ms_isr() as a custom mutex for ms_delay() without a need for
      explicit unlocking.  I converted that to a standard mutex.
      
      The replacement for the unconditional sleep_on() in fd_motor_on() is a
      complete_all() together with a INIT_COMPLETION() before the mod_timer()
      call.  It appears to me that fd_motor_on() might be called concurrently
      and fd_select() does not guarantee mutual exclusivity in the case the
      same drive gets selected again.
      Signed-off-by: NAndreas Bombe <aeb@debian.org>
      Acked-by: NJörg Dorchain <joerg@dorchain.net>
      Signed-off-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      6d0be946
  21. 10 1月, 2009 1 次提交
  22. 08 1月, 2009 1 次提交
    • A
      USB: change interface to usb_lock_device_for_reset() · 011b15df
      Alan Stern 提交于
      This patch (as1161) changes the interface to
      usb_lock_device_for_reset().  The existing interface is apparently not
      very clear, judging from the fact that several of its callers don't
      use it correctly.  The new interface always returns 0 for success and
      it always requires the caller to unlock the device afterward.
      
      The new routine will not return immediately if it is called while the
      driver's probe method is running.  Instead it will wait until the
      probe is over and the device has been unlocked.  This shouldn't cause
      any problems; I don't know of any cases where drivers call
      usb_lock_device_for_reset() during probe.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: Pete Zaitcev <zaitcev@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      011b15df
  23. 07 1月, 2009 2 次提交
  24. 06 1月, 2009 1 次提交
  25. 05 1月, 2009 1 次提交
    • A
      bzip2/lzma: config and initramfs support for bzip2/lzma decompression · 30d65dbf
      Alain Knaff 提交于
      Impact: New code for initramfs decompression, new features
      
      This is the second part of the bzip2/lzma patch
      
      The bzip patch is based on an idea by Christian Ludwig, includes support for
      compressing the kernel with bzip2 or lzma rather than gzip. Both
      compressors give smaller sizes than gzip.  Lzma's decompresses faster
      than bzip2.
      
      It also supports ramdisks and initramfs' compressed using these two
      compressors.
      
      The functionality has been successfully used for a couple of years by
      the udpcast project
      
      This version applies to "tip" kernel 2.6.28
      
      This part contains:
      - support for new compressions (bzip2 and lzma) in initramfs and
      old-style ramdisk
      - config dialog for kernel compression (but new kernel compressions
      not yet supported)
      Signed-off-by: NAlain Knaff <alain@knaff.lu>
      Signed-off-by: NH. Peter Anvin <hpa@zytor.com>
      30d65dbf