aboutsummaryrefslogtreecommitdiffstats
path: root/fs/block_dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index db831efbdbbd..99e0ae1a4c78 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1135,12 +1135,15 @@ static int blkdev_open(struct inode * inode, struct file * filp)
1135 if (res) 1135 if (res)
1136 return res; 1136 return res;
1137 1137
1138 if (!(filp->f_mode & FMODE_EXCL)) 1138 if (filp->f_mode & FMODE_EXCL) {
1139 return 0; 1139 res = bd_claim(bdev, filp);
1140 if (res)
1141 goto out_blkdev_put;
1142 }
1140 1143
1141 if (!(res = bd_claim(bdev, filp))) 1144 return 0;
1142 return 0;
1143 1145
1146 out_blkdev_put:
1144 blkdev_put(bdev, filp->f_mode); 1147 blkdev_put(bdev, filp->f_mode);
1145 return res; 1148 return res;
1146} 1149}
@@ -1203,8 +1206,16 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
1203{ 1206{
1204 struct block_device *bdev = I_BDEV(file->f_mapping->host); 1207 struct block_device *bdev = I_BDEV(file->f_mapping->host);
1205 fmode_t mode = file->f_mode; 1208 fmode_t mode = file->f_mode;
1209
1210 /*
1211 * O_NDELAY can be altered using fcntl(.., F_SETFL, ..), so we have
1212 * to updated it before every ioctl.
1213 */
1206 if (file->f_flags & O_NDELAY) 1214 if (file->f_flags & O_NDELAY)
1207 mode |= FMODE_NDELAY_NOW; 1215 mode |= FMODE_NDELAY;
1216 else
1217 mode &= ~FMODE_NDELAY;
1218
1208 return blkdev_ioctl(bdev, mode, cmd, arg); 1219 return blkdev_ioctl(bdev, mode, cmd, arg);
1209} 1220}
1210 1221