patch-2.4.0-test2 linux/drivers/block/loop.c
Next file: linux/drivers/block/md.c
Previous file: linux/drivers/block/ll_rw_blk.c
Back to the patch index
Back to the overall index
- Lines: 113
- Date:
Wed Jun 21 22:31:00 2000
- Orig file:
v2.4.0-test1/linux/drivers/block/loop.c
- Orig date:
Tue May 23 15:31:34 2000
diff -u --recursive --new-file v2.4.0-test1/linux/drivers/block/loop.c linux/drivers/block/loop.c
@@ -238,7 +238,8 @@
kaddr = (char*)kmap(page);
if ((lo->transfer)(lo,READ,kaddr+offset,p->data,size,IV)) {
size = 0;
- printk(KERN_ERR "loop: transfer error block %ld\n",page->index);
+ printk(KERN_ERR "loop: transfer error block %ld\n",
+ page->index);
desc->error = -EINVAL;
}
kunmap(page);
@@ -345,9 +346,11 @@
}
}
- if ((lo->transfer)(lo, current_request->cmd, bh->b_data + offset,
- dest_addr, size, block)) {
- printk(KERN_ERR "loop: transfer error block %d\n", block);
+ if ((lo->transfer)(lo, current_request->cmd,
+ bh->b_data + offset,
+ dest_addr, size, block)) {
+ printk(KERN_ERR "loop: transfer error block %d\n",
+ block);
brelse(bh);
goto error_out_lock;
}
@@ -469,7 +472,7 @@
lo->lo_backing_file->f_owner = file->f_owner;
lo->lo_backing_file->f_dentry = file->f_dentry;
lo->lo_backing_file->f_vfsmnt = mntget(file->f_vfsmnt);
- lo->lo_backing_file->f_op = file->f_op;
+ lo->lo_backing_file->f_op = fops_get(file->f_op);
lo->lo_backing_file->private_data = file->private_data;
file_moveto(lo->lo_backing_file, file);
@@ -539,8 +542,10 @@
lo->lo_dentry = NULL;
if (lo->lo_backing_file != NULL) {
- put_write_access(lo->lo_backing_file->f_dentry->d_inode);
- fput(lo->lo_backing_file);
+ struct file *filp = lo->lo_backing_file;
+ if ((filp->f_mode & FMODE_WRITE) == 0)
+ put_write_access(filp->f_dentry->d_inode);
+ fput(filp);
lo->lo_backing_file = NULL;
} else {
dput(dentry);
@@ -636,7 +641,8 @@
if (!inode)
return -EINVAL;
if (MAJOR(inode->i_rdev) != MAJOR_NR) {
- printk(KERN_WARNING "lo_ioctl: pseudo-major != %d\n", MAJOR_NR);
+ printk(KERN_WARNING "lo_ioctl: pseudo-major != %d\n",
+ MAJOR_NR);
return -ENODEV;
}
dev = MINOR(inode->i_rdev);
@@ -698,7 +704,8 @@
if (!inode)
return 0;
if (MAJOR(inode->i_rdev) != MAJOR_NR) {
- printk(KERN_WARNING "lo_release: pseudo-major != %d\n", MAJOR_NR);
+ printk(KERN_WARNING "lo_release: pseudo-major != %d\n",
+ MAJOR_NR);
return 0;
}
dev = MINOR(inode->i_rdev);
@@ -706,7 +713,8 @@
return 0;
lo = &loop_dev[dev];
if (lo->lo_refcnt <= 0)
- printk(KERN_ERR "lo_release: refcount(%d) <= 0\n", lo->lo_refcnt);
+ printk(KERN_ERR "lo_release: refcount(%d) <= 0\n",
+ lo->lo_refcnt);
else {
int type = lo->lo_encrypt_type;
--lo->lo_refcnt;
@@ -761,6 +769,10 @@
EXPORT_SYMBOL(loop_register_transfer);
EXPORT_SYMBOL(loop_unregister_transfer);
+static void no_plug_device(request_queue_t *q, kdev_t device)
+{
+}
+
int __init loop_init(void)
{
int i;
@@ -773,7 +785,7 @@
devfs_handle = devfs_mk_dir (NULL, "loop", 0, NULL);
devfs_register_series (devfs_handle, "%u", max_loop, DEVFS_FL_DEFAULT,
MAJOR_NR, 0,
- S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0,
+ S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP,
&lo_fops, NULL);
if ((max_loop < 1) || (max_loop > 255)) {
@@ -806,6 +818,7 @@
}
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
+ blk_queue_pluggable(BLK_DEFAULT_QUEUE(MAJOR_NR), no_plug_device);
blk_queue_headactive(BLK_DEFAULT_QUEUE(MAJOR_NR), 0);
for (i=0; i < max_loop; i++) {
memset(&loop_dev[i], 0, sizeof(struct loop_device));
@@ -828,6 +841,7 @@
if (devfs_unregister_blkdev(MAJOR_NR, "loop") != 0)
printk(KERN_WARNING "loop: cannot unregister blkdev\n");
+ blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
kfree (loop_dev);
kfree (loop_sizes);
kfree (loop_blksizes);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)