Whamcloud - gitweb
LU-540 lloop: fix LLOOP_INFO to return FID
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 27 Jul 2011 05:25:18 +0000 (23:25 -0600)
committerOleg Drokin <green@whamcloud.com>
Fri, 29 Jul 2011 15:03:28 +0000 (11:03 -0400)
Instead of returning an inode number to userspace for the LLOOP_INFO
ioctl, instead return a FID value.

This does not pose compatibility problems, because the ioctl() number
was already different between Lustre 1.x and 2.x, and the lctl needed
for using lloop devices is always built with the kernel modules.

Change-Id: Ia3ee6dab830ad65e2a11d9248982c82ce76221f1
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1149
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Jinshan Xiong <jay@whamcloud.com>
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre/lustre_user.h
lustre/llite/lloop.c
lustre/utils/obd.c

index 7a8faf0..0b42fa9 100644 (file)
@@ -142,7 +142,7 @@ struct obd_statfs {
 #define LL_IOC_GETOBDCOUNT              _IOR ('f', 168, long)
 #define LL_IOC_LLOOP_ATTACH             _IOWR('f', 169, long)
 #define LL_IOC_LLOOP_DETACH             _IOWR('f', 170, long)
-#define LL_IOC_LLOOP_INFO               _IOWR('f', 171, long)
+#define LL_IOC_LLOOP_INFO               _IOWR('f', 171, struct lu_fid)
 #define LL_IOC_LLOOP_DETACH_BYDEV       _IOWR('f', 172, long)
 #define LL_IOC_PATH2FID                 _IOR ('f', 173, long)
 #define LL_IOC_GET_CONNECT_FLAGS        _IOWR('f', 174, __u64 *)
index f7d4654..3b13aab 100644 (file)
@@ -641,6 +641,7 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
                     unsigned int cmd, unsigned long arg)
 {
         struct lloop_device *lo = bdev->bd_disk->private_data;
+        struct inode *inode = lo->lo_backing_file->f_dentry->d_inode;
 #else
 static int lo_ioctl(struct inode *inode, struct file *unused,
                     unsigned int cmd, unsigned long arg)
@@ -660,12 +661,14 @@ static int lo_ioctl(struct inode *inode, struct file *unused,
         }
 
         case LL_IOC_LLOOP_INFO: {
-                __u64 ino = 0;
+                struct lu_fid fid;
 
                 if (lo->lo_state == LLOOP_BOUND)
-                        ino = lo->lo_backing_file->f_dentry->d_inode->i_ino;
+                        fid = ll_i2info(inode)->lli_fid;
+                else
+                        fid_zero(&fid);
 
-                if (put_user(ino, (__u64 *)arg))
+                if (copy_to_user((struct lu_fid *)arg, &fid, sizeof(fid)))
                         err = -EFAULT;
                 break;
         }
index 0ff3100..2a84949 100644 (file)
@@ -2455,7 +2455,7 @@ int jt_blockdev_info(int argc, char **argv)
 {
         char *filename;
         int rc, fd;
-        __u64  ino;
+        struct lu_fid fid;
 
         if (argc != 2)
                 return CMD_HELP;
@@ -2468,17 +2468,17 @@ int jt_blockdev_info(int argc, char **argv)
                 return CMD_HELP;
         }
 
-        rc = ioctl(fd, LL_IOC_LLOOP_INFO, &ino);
+        rc = ioctl(fd, LL_IOC_LLOOP_INFO, &fid);
         if (rc < 0) {
                 rc = errno;
                 fprintf(stderr, "error: %s\n", strerror(errno));
                 goto out;
         }
         fprintf(stdout, "lloop device info: ");
-        if (ino == 0ULL)
+        if (fid_is_zero(&fid))
                 fprintf(stdout, "Not attached\n");
         else
-                fprintf(stdout, "attached to inode "LPU64"\n", ino);
+                fprintf(stdout, "attached to inode "DFID"\n", PFID(&fid));
 out:
         close(fd);
         return -rc;