@@ -64,6 +64,7 @@ static struct se_device *iblock_alloc_device(struct se_hba *hba, const char *nam
64
64
pr_err ("Unable to allocate struct iblock_dev\n" );
65
65
return NULL ;
66
66
}
67
+ ib_dev -> ibd_exclusive = true;
67
68
68
69
ib_dev -> ibd_plug = kcalloc (nr_cpu_ids , sizeof (* ib_dev -> ibd_plug ),
69
70
GFP_KERNEL );
@@ -95,6 +96,7 @@ static int iblock_configure_device(struct se_device *dev)
95
96
struct block_device * bd ;
96
97
struct blk_integrity * bi ;
97
98
blk_mode_t mode = BLK_OPEN_READ ;
99
+ void * holder = ib_dev ;
98
100
unsigned int max_write_zeroes_sectors ;
99
101
int ret ;
100
102
@@ -109,15 +111,18 @@ static int iblock_configure_device(struct se_device *dev)
109
111
goto out ;
110
112
}
111
113
112
- pr_debug ( "IBLOCK: Claiming struct block_device: %s\n" ,
113
- ib_dev -> ibd_udev_path );
114
+ pr_debug ("IBLOCK: Claiming struct block_device: %s: %d \n" ,
115
+ ib_dev -> ibd_udev_path , ib_dev -> ibd_exclusive );
114
116
115
117
if (!ib_dev -> ibd_readonly )
116
118
mode |= BLK_OPEN_WRITE ;
117
119
else
118
120
dev -> dev_flags |= DF_READ_ONLY ;
119
121
120
- bdev_file = bdev_file_open_by_path (ib_dev -> ibd_udev_path , mode , ib_dev ,
122
+ if (!ib_dev -> ibd_exclusive )
123
+ holder = NULL ;
124
+
125
+ bdev_file = bdev_file_open_by_path (ib_dev -> ibd_udev_path , mode , holder ,
121
126
NULL );
122
127
if (IS_ERR (bdev_file )) {
123
128
ret = PTR_ERR (bdev_file );
@@ -560,13 +565,14 @@ iblock_execute_write_same(struct se_cmd *cmd)
560
565
}
561
566
562
567
enum {
563
- Opt_udev_path , Opt_readonly , Opt_force , Opt_err
568
+ Opt_udev_path , Opt_readonly , Opt_force , Opt_exclusive , Opt_err ,
564
569
};
565
570
566
571
static match_table_t tokens = {
567
572
{Opt_udev_path , "udev_path=%s" },
568
573
{Opt_readonly , "readonly=%d" },
569
574
{Opt_force , "force=%d" },
575
+ {Opt_exclusive , "exclusive=%d" },
570
576
{Opt_err , NULL }
571
577
};
572
578
@@ -576,7 +582,7 @@ static ssize_t iblock_set_configfs_dev_params(struct se_device *dev,
576
582
struct iblock_dev * ib_dev = IBLOCK_DEV (dev );
577
583
char * orig , * ptr , * arg_p , * opts ;
578
584
substring_t args [MAX_OPT_ARGS ];
579
- int ret = 0 , token ;
585
+ int ret = 0 , token , tmp_exclusive ;
580
586
unsigned long tmp_readonly ;
581
587
582
588
opts = kstrdup (page , GFP_KERNEL );
@@ -623,6 +629,22 @@ static ssize_t iblock_set_configfs_dev_params(struct se_device *dev,
623
629
ib_dev -> ibd_readonly = tmp_readonly ;
624
630
pr_debug ("IBLOCK: readonly: %d\n" , ib_dev -> ibd_readonly );
625
631
break ;
632
+ case Opt_exclusive :
633
+ arg_p = match_strdup (& args [0 ]);
634
+ if (!arg_p ) {
635
+ ret = - ENOMEM ;
636
+ break ;
637
+ }
638
+ ret = kstrtoint (arg_p , 0 , & tmp_exclusive );
639
+ kfree (arg_p );
640
+ if (ret < 0 ) {
641
+ pr_err ("kstrtoul() failed for exclusive=\n" );
642
+ goto out ;
643
+ }
644
+ ib_dev -> ibd_exclusive = tmp_exclusive ;
645
+ pr_debug ("IBLOCK: exclusive: %d\n" ,
646
+ ib_dev -> ibd_exclusive );
647
+ break ;
626
648
case Opt_force :
627
649
break ;
628
650
default :
@@ -647,6 +669,7 @@ static ssize_t iblock_show_configfs_dev_params(struct se_device *dev, char *b)
647
669
bl += sprintf (b + bl , " UDEV PATH: %s" ,
648
670
ib_dev -> ibd_udev_path );
649
671
bl += sprintf (b + bl , " readonly: %d\n" , ib_dev -> ibd_readonly );
672
+ bl += sprintf (b + bl , " exclusive: %d\n" , ib_dev -> ibd_exclusive );
650
673
651
674
bl += sprintf (b + bl , " " );
652
675
if (bd ) {
0 commit comments