Linus (et al),

 The raid code wants to be the sole accessor of any devices are are
 combined into the array.  i.e. it want to lock those devices agaist
 other use.

 It currently tried to do this bby creating an inode that appears to
 be associated with that device.
 This no longer has any useful effect (and I don't think it has for a
 while, though I haven't dug into the history).

 I have changed the lock_rdev code to simple do a blkdev_get when
 attaching the device, and a blkdev_put when releasing it.  This
 atleast makes sure that if the device is in a module it wont be
 unloaded.
 Any further exclusive access control will needed to go into the
 blkdev_{get,put} routines at some stage I think.

 patch against 2.4.0-test12-pre8

NeilBrown


--- ./include/linux/raid/md_k.h 2000/12/10 23:21:26     1.2
+++ ./include/linux/raid/md_k.h 2000/12/10 23:33:07     1.3
@@ -165,8 +165,7 @@
        mddev_t *mddev;                 /* RAID array if running */
        unsigned long last_events;      /* IO event timestamp */
 
-       struct inode *inode;            /* Lock inode */
-       struct file filp;               /* Lock file */
+       struct block_device *bdev;      /* block device handle */
 
        mdp_super_t *sb;
        unsigned long sb_offset;
--- ./drivers/md/md.c   2000/12/10 23:21:26     1.4
+++ ./drivers/md/md.c   2000/12/10 23:33:08     1.5
@@ -657,32 +657,25 @@
 static int lock_rdev (mdk_rdev_t *rdev)
 {
        int err = 0;
+       struct block_device *bdev;
 
-       /*
-        * First insert a dummy inode.
-        */
-       if (rdev->inode)
-               MD_BUG();
-       rdev->inode = get_empty_inode();
-       if (!rdev->inode)
+       bdev = bdget(rdev->dev);
+       if (bdev == NULL)
                return -ENOMEM;
-       /*
-        * we dont care about any other fields
-        */
-       rdev->inode->i_dev = rdev->inode->i_rdev = rdev->dev;
-       insert_inode_hash(rdev->inode);
-
-       memset(&rdev->filp, 0, sizeof(rdev->filp));
-       rdev->filp.f_mode = 3; /* read write */
+       err = blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_FILE);
+       if (!err) {
+               rdev->bdev = bdev;
+       }
        return err;
 }
 
 static void unlock_rdev (mdk_rdev_t *rdev)
 {
-       if (!rdev->inode)
+       if (!rdev->bdev)
                MD_BUG();
-       iput(rdev->inode);
-       rdev->inode = NULL;
+       blkdev_put(rdev->bdev, BDEV_FILE);
+       bdput(rdev->bdev);
+       rdev->bdev = NULL;
 }
 
 static void export_rdev (mdk_rdev_t * rdev)
@@ -1150,7 +1143,7 @@
 
 abort_free:
        if (rdev->sb) {
-               if (rdev->inode)
+               if (rdev->bdev)
                        unlock_rdev(rdev);
                free_disk_sb(rdev);
        }
-
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to [EMAIL PROTECTED]

Reply via email to