OSDN Git Service

switch coda get_device_index() to fget_light()
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 27 Aug 2012 16:54:13 +0000 (12:54 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 27 Sep 2012 01:10:10 +0000 (21:10 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/coda/inode.c

index f181312..bd2313d 100644 (file)
@@ -109,41 +109,39 @@ static int get_device_index(struct coda_mount_data *data)
 {
        struct file *file;
        struct inode *inode;
-       int idx;
+       int idx, fput_needed;
 
-       if(data == NULL) {
+       if (data == NULL) {
                printk("coda_read_super: Bad mount data\n");
                return -1;
        }
 
-       if(data->version != CODA_MOUNT_VERSION) {
+       if (data->version != CODA_MOUNT_VERSION) {
                printk("coda_read_super: Bad mount version\n");
                return -1;
        }
 
-       file = fget(data->fd);
-       inode = NULL;
-       if(file)
-               inode = file->f_path.dentry->d_inode;
-       
-       if(!inode || !S_ISCHR(inode->i_mode) ||
-          imajor(inode) != CODA_PSDEV_MAJOR) {
-               if(file)
-                       fput(file);
-
-               printk("coda_read_super: Bad file\n");
-               return -1;
+       file = fget_light(data->fd, &fput_needed);
+       if (!file)
+               goto Ebadf;
+       inode = file->f_path.dentry->d_inode;
+       if (!S_ISCHR(inode->i_mode) || imajor(inode) != CODA_PSDEV_MAJOR) {
+               fput_light(file, fput_needed);
+               goto Ebadf;
        }
 
        idx = iminor(inode);
-       fput(file);
+       fput_light(file, fput_needed);
 
-       if(idx < 0 || idx >= MAX_CODADEVS) {
+       if (idx < 0 || idx >= MAX_CODADEVS) {
                printk("coda_read_super: Bad minor number\n");
                return -1;
        }
 
        return idx;
+Ebadf:
+       printk("coda_read_super: Bad file\n");
+       return -1;
 }
 
 static int coda_fill_super(struct super_block *sb, void *data, int silent)