CFS: Fix missing digit off in wmult table
[platform/kernel/linux-starfive.git] / drivers / block / nbd.c
index 9d1035e..c575fb1 100644 (file)
@@ -355,15 +355,36 @@ harderror:
        return NULL;
 }
 
-static void nbd_do_it(struct nbd_device *lo)
+static ssize_t pid_show(struct gendisk *disk, char *page)
+{
+       return sprintf(page, "%ld\n",
+               (long) ((struct nbd_device *)disk->private_data)->pid);
+}
+
+static struct disk_attribute pid_attr = {
+       .attr = { .name = "pid", .mode = S_IRUGO },
+       .show = pid_show,
+};
+
+static int nbd_do_it(struct nbd_device *lo)
 {
        struct request *req;
+       int ret;
 
        BUG_ON(lo->magic != LO_MAGIC);
 
+       lo->pid = current->pid;
+       ret = sysfs_create_file(&lo->disk->kobj, &pid_attr.attr);
+       if (ret) {
+               printk(KERN_ERR "nbd: sysfs_create_file failed!");
+               return ret;
+       }
+
        while ((req = nbd_read_stat(lo)) != NULL)
                nbd_end_request(req);
-       return;
+
+       sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr);
+       return 0;
 }
 
 static void nbd_clear_que(struct nbd_device *lo)
@@ -395,7 +416,7 @@ static void nbd_clear_que(struct nbd_device *lo)
 /*
  * We always wait for result of write, for now. It would be nice to make it optional
  * in future
- * if ((req->cmd == WRITE) && (lo->flags & NBD_WRITE_NOCHK)) 
+ * if ((rq_data_dir(req) == WRITE) && (lo->flags & NBD_WRITE_NOCHK))
  *   { printk( "Warning: Ignoring result!\n"); nbd_end_request( req ); }
  */
 
@@ -521,7 +542,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
                error = -EINVAL;
                file = fget(arg);
                if (file) {
-                       inode = file->f_dentry->d_inode;
+                       inode = file->f_path.dentry->d_inode;
                        if (S_ISSOCK(inode->i_mode)) {
                                lo->file = file;
                                lo->sock = SOCKET_I(inode);
@@ -553,7 +574,9 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
        case NBD_DO_IT:
                if (!lo->file)
                        return -EINVAL;
-               nbd_do_it(lo);
+               error = nbd_do_it(lo);
+               if (error)
+                       return error;
                /* on return tidy up in case we have a signal */
                /* Forcibly shutdown the socket causing all listeners
                 * to error