Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
4d466c1f
Commit
4d466c1f
authored
Oct 28, 2002
by
Alexander Viro
Committed by
James Bottomley
Oct 28, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] r/o state moved to gendisks
parent
1bec5152
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
58 additions
and
63 deletions
+58
-63
drivers/block/genhd.c
drivers/block/genhd.c
+37
-0
drivers/block/ioctl.c
drivers/block/ioctl.c
+1
-1
drivers/block/ll_rw_blk.c
drivers/block/ll_rw_blk.c
+0
-28
drivers/block/loop.c
drivers/block/loop.c
+1
-2
drivers/ide/ide-cd.c
drivers/ide/ide-cd.c
+2
-2
drivers/md/md.c
drivers/md/md.c
+7
-6
drivers/mtd/mtdblock.c
drivers/mtd/mtdblock.c
+1
-1
drivers/mtd/mtdblock_ro.c
drivers/mtd/mtdblock_ro.c
+1
-1
drivers/s390/block/dasd.c
drivers/s390/block/dasd.c
+0
-13
drivers/s390/block/dasd_genhd.c
drivers/s390/block/dasd_genhd.c
+2
-0
drivers/s390/block/dasd_ioctl.c
drivers/s390/block/dasd_ioctl.c
+1
-2
drivers/sbus/char/jsflash.c
drivers/sbus/char/jsflash.c
+1
-1
include/linux/blk.h
include/linux/blk.h
+2
-1
include/linux/genhd.h
include/linux/genhd.h
+2
-1
kernel/ksyms.c
kernel/ksyms.c
+0
-4
No files found.
drivers/block/genhd.c
View file @
4d466c1f
...
...
@@ -336,3 +336,40 @@ void put_disk(struct gendisk *disk)
EXPORT_SYMBOL
(
alloc_disk
);
EXPORT_SYMBOL
(
get_disk
);
EXPORT_SYMBOL
(
put_disk
);
void
set_device_ro
(
struct
block_device
*
bdev
,
int
flag
)
{
struct
gendisk
*
disk
=
bdev
->
bd_disk
;
if
(
bdev
->
bd_contains
!=
bdev
)
{
int
part
=
bdev
->
bd_dev
-
MKDEV
(
disk
->
major
,
disk
->
first_minor
);
struct
hd_struct
*
p
=
&
disk
->
part
[
part
-
1
];
p
->
policy
=
flag
;
}
else
disk
->
policy
=
flag
;
}
void
set_disk_ro
(
struct
gendisk
*
disk
,
int
flag
)
{
int
i
;
disk
->
policy
=
flag
;
for
(
i
=
0
;
i
<
disk
->
minors
;
i
++
)
disk
->
part
[
i
].
policy
=
flag
;
}
int
bdev_read_only
(
struct
block_device
*
bdev
)
{
struct
gendisk
*
disk
;
if
(
!
bdev
)
return
0
;
disk
=
bdev
->
bd_disk
;
if
(
bdev
->
bd_contains
!=
bdev
)
{
int
part
=
bdev
->
bd_dev
-
MKDEV
(
disk
->
major
,
disk
->
first_minor
);
struct
hd_struct
*
p
=
&
disk
->
part
[
part
-
1
];
return
p
->
policy
;
}
else
return
disk
->
policy
;
}
EXPORT_SYMBOL
(
bdev_read_only
);
EXPORT_SYMBOL
(
set_device_ro
);
EXPORT_SYMBOL
(
set_disk_ro
);
drivers/block/ioctl.c
View file @
4d466c1f
...
...
@@ -202,7 +202,7 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
return
-
EACCES
;
if
(
get_user
(
n
,
(
int
*
)(
arg
)))
return
-
EFAULT
;
set_device_ro
(
to_kdev_t
(
bdev
->
bd_dev
)
,
n
);
set_device_ro
(
bdev
,
n
);
return
0
;
default:
if
(
bdev
->
bd_op
->
ioctl
)
{
...
...
drivers/block/ll_rw_blk.c
View file @
4d466c1f
...
...
@@ -1404,34 +1404,6 @@ void blk_insert_request(request_queue_t *q, struct request *rq,
spin_unlock_irqrestore
(
q
->
queue_lock
,
flags
);
}
/* RO fail safe mechanism */
static
long
ro_bits
[
MAX_BLKDEV
][
8
];
int
bdev_read_only
(
struct
block_device
*
bdev
)
{
int
minor
,
major
;
if
(
!
bdev
)
return
0
;
major
=
MAJOR
(
bdev
->
bd_dev
);
minor
=
MINOR
(
bdev
->
bd_dev
);
if
(
major
<
0
||
major
>=
MAX_BLKDEV
)
return
0
;
return
ro_bits
[
major
][
minor
>>
5
]
&
(
1
<<
(
minor
&
31
));
}
void
set_device_ro
(
kdev_t
dev
,
int
flag
)
{
int
minor
,
major
;
major
=
major
(
dev
);
minor
=
minor
(
dev
);
if
(
major
<
0
||
major
>=
MAX_BLKDEV
)
return
;
if
(
flag
)
ro_bits
[
major
][
minor
>>
5
]
|=
1
<<
(
minor
&
31
);
else
ro_bits
[
major
][
minor
>>
5
]
&=
~
(
1
<<
(
minor
&
31
));
}
void
drive_stat_acct
(
struct
request
*
rq
,
int
nr_sectors
,
int
new_io
)
{
unsigned
int
major
=
major
(
rq
->
rq_dev
);
...
...
drivers/block/loop.c
View file @
4d466c1f
...
...
@@ -650,7 +650,6 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
{
struct
file
*
file
;
struct
inode
*
inode
;
kdev_t
dev
=
to_kdev_t
(
bdev
->
bd_dev
);
struct
block_device
*
lo_device
;
int
lo_flags
=
0
;
int
error
;
...
...
@@ -702,7 +701,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
||
!
(
lo_file
->
f_mode
&
FMODE_WRITE
))
lo_flags
|=
LO_FLAGS_READ_ONLY
;
set_device_ro
(
dev
,
(
lo_flags
&
LO_FLAGS_READ_ONLY
)
!=
0
);
set_device_ro
(
b
dev
,
(
lo_flags
&
LO_FLAGS_READ_ONLY
)
!=
0
);
lo
->
lo_device
=
lo_device
;
lo
->
lo_flags
=
lo_flags
;
...
...
drivers/ide/ide-cd.c
View file @
4d466c1f
...
...
@@ -3062,7 +3062,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
/*
* default to read-only always and fix latter at the bottom
*/
set_d
evice_ro
(
mk_kdev
(
drive
->
disk
->
major
,
drive
->
disk
->
first_minor
)
,
1
);
set_d
isk_ro
(
drive
->
disk
,
1
);
blk_queue_hardsect_size
(
&
drive
->
queue
,
CD_FRAMESIZE
);
blk_queue_prep_rq
(
&
drive
->
queue
,
ide_cdrom_prep_fn
);
...
...
@@ -3185,7 +3185,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
nslots
=
ide_cdrom_probe_capabilities
(
drive
);
if
(
CDROM_CONFIG_FLAGS
(
drive
)
->
dvd_ram
)
set_d
evice_ro
(
mk_kdev
(
drive
->
disk
->
major
,
drive
->
disk
->
first_minor
)
,
0
);
set_d
isk_ro
(
drive
->
disk
,
0
);
#if 0
drive->dsc_overlap = (HWIF(drive)->no_dsc) ? 0 : 1;
...
...
drivers/md/md.c
View file @
4d466c1f
...
...
@@ -1467,6 +1467,7 @@ static int do_md_run(mddev_t * mddev)
static
int
restart_array
(
mddev_t
*
mddev
)
{
struct
gendisk
*
disk
=
disks
[
mdidx
(
mddev
)];
int
err
;
/*
...
...
@@ -1482,7 +1483,7 @@ static int restart_array(mddev_t *mddev)
goto
out
;
mddev
->
ro
=
0
;
set_d
evice_ro
(
mddev_to_kdev
(
mddev
)
,
0
);
set_d
isk_ro
(
disk
,
0
);
printk
(
KERN_INFO
"md: md%d switched to read-write mode.
\n
"
,
mdidx
(
mddev
));
...
...
@@ -1509,7 +1510,7 @@ static int restart_array(mddev_t *mddev)
static
int
do_md_stop
(
mddev_t
*
mddev
,
int
ro
)
{
int
err
=
0
;
kdev_t
dev
=
mddev_to_kdev
(
mddev
)
;
struct
gendisk
*
disk
=
disks
[
mdidx
(
mddev
)]
;
if
(
atomic_read
(
&
mddev
->
active
)
>
1
)
{
printk
(
STILL_IN_USE
,
mdidx
(
mddev
));
...
...
@@ -1525,7 +1526,7 @@ static int do_md_stop(mddev_t * mddev, int ro)
mddev
->
sync_thread
=
NULL
;
}
invalidate_device
(
dev
,
1
);
invalidate_device
(
mk_kdev
(
disk
->
major
,
disk
->
first_minor
)
,
1
);
if
(
ro
)
{
err
=
-
ENXIO
;
...
...
@@ -1534,11 +1535,11 @@ static int do_md_stop(mddev_t * mddev, int ro)
mddev
->
ro
=
1
;
}
else
{
if
(
mddev
->
ro
)
set_d
evice_ro
(
dev
,
0
);
set_d
isk_ro
(
disk
,
0
);
if
(
mddev
->
pers
->
stop
(
mddev
))
{
err
=
-
EBUSY
;
if
(
mddev
->
ro
)
set_d
evice_ro
(
dev
,
1
);
set_d
isk_ro
(
disk
,
1
);
goto
out
;
}
if
(
mddev
->
ro
)
...
...
@@ -1556,7 +1557,7 @@ static int do_md_stop(mddev_t * mddev, int ro)
md_update_sb
(
mddev
);
}
if
(
ro
)
set_d
evice_ro
(
dev
,
1
);
set_d
isk_ro
(
disk
,
1
);
}
/*
* Free resources if final stop
...
...
drivers/mtd/mtdblock.c
View file @
4d466c1f
...
...
@@ -330,7 +330,7 @@ static int mtdblock_open(struct inode *inode, struct file *file)
}
mtdblks
[
dev
]
=
mtdblk
;
set_device_ro
(
inode
->
i_r
dev
,
!
(
mtdblk
->
mtd
->
flags
&
MTD_WRITEABLE
));
set_device_ro
(
inode
->
i_b
dev
,
!
(
mtdblk
->
mtd
->
flags
&
MTD_WRITEABLE
));
spin_unlock
(
&
mtdblks_lock
);
...
...
drivers/mtd/mtdblock_ro.c
View file @
4d466c1f
...
...
@@ -58,7 +58,7 @@ static int mtdblock_open(struct inode *inode, struct file *file)
}
if
(
ret
==
0
)
{
set_device_ro
(
inode
->
i_
r
dev
,
!
(
mdev
->
mtd
->
flags
&
MTD_CAP_RAM
));
set_device_ro
(
inode
->
i_
b
dev
,
!
(
mdev
->
mtd
->
flags
&
MTD_CAP_RAM
));
mdev
->
open
++
;
}
up
(
&
mtd_sem
);
...
...
drivers/s390/block/dasd.c
View file @
4d466c1f
...
...
@@ -427,17 +427,6 @@ dasd_state_accept_to_basic(dasd_device_t * device)
device
->
state
=
DASD_STATE_BASIC
;
}
/*
* get the kdev_t of a device
* FIXME: remove this when no longer needed
*/
static
inline
kdev_t
dasd_partition_to_kdev_t
(
dasd_device_t
*
device
,
unsigned
int
partition
)
{
return
mk_kdev
(
device
->
gdp
->
major
,
device
->
gdp
->
first_minor
+
partition
);
}
/*
* Setup block device.
*/
...
...
@@ -449,8 +438,6 @@ dasd_state_accept_to_ready(dasd_device_t * device)
devmap
=
dasd_devmap_from_devno
(
device
->
devinfo
.
devno
);
if
(
devmap
->
features
&
DASD_FEATURE_READONLY
)
{
for
(
i
=
0
;
i
<
(
1
<<
DASD_PARTN_BITS
);
i
++
)
set_device_ro
(
dasd_partition_to_kdev_t
(
device
,
i
),
1
);
device
->
ro_flag
=
1
;
DEV_MESSAGE
(
KERN_WARNING
,
device
,
"%s"
,
"setting read-only mode "
);
...
...
drivers/s390/block/dasd_genhd.c
View file @
4d466c1f
...
...
@@ -249,6 +249,8 @@ dasd_setup_partitions(dasd_device_t * device)
/* Make the disk known. */
set_capacity
(
device
->
gdp
,
device
->
blocks
<<
device
->
s2b_shift
);
device
->
gdp
->
queue
=
device
->
request_queue
;
if
(
device
->
ro_flag
)
set_disk_ro
(
device
->
gdp
,
1
);
add_disk
(
device
->
gdp
);
}
...
...
drivers/s390/block/dasd_ioctl.c
View file @
4d466c1f
...
...
@@ -462,8 +462,7 @@ dasd_ioctl_set_ro(struct block_device *bdev, int no, long args)
devmap
->
features
|=
DASD_FEATURE_READONLY
;
else
devmap
->
features
&=
~
DASD_FEATURE_READONLY
;
for
(
i
=
0
;
i
<
(
1
<<
DASD_PARTN_BITS
);
i
++
)
set_device_ro
(
to_kdev_t
(
bdev
->
bd_dev
+
i
),
intval
);
set_disk_ro
(
bdev
->
bd_disk
,
intval
);
device
->
ro_flag
=
intval
;
dasd_put_device
(
devmap
);
return
0
;
...
...
drivers/sbus/char/jsflash.c
View file @
4d466c1f
...
...
@@ -592,7 +592,7 @@ static int jsfd_init(void)
disk
->
private_data
=
jdp
;
disk
->
queue
=
&
jsf_queue
;
add_disk
(
disk
);
set_d
evice_ro
(
MKDEV
(
JSFD_MAJOR
,
i
)
,
1
);
set_d
isk_ro
(
disk
,
1
);
}
return
0
;
out:
...
...
include/linux/blk.h
View file @
4d466c1f
...
...
@@ -7,7 +7,8 @@
#include <linux/spinlock.h>
#include <linux/compiler.h>
extern
void
set_device_ro
(
kdev_t
dev
,
int
flag
);
extern
void
set_device_ro
(
struct
block_device
*
bdev
,
int
flag
);
extern
void
set_disk_ro
(
struct
gendisk
*
disk
,
int
flag
);
extern
void
add_disk_randomness
(
struct
gendisk
*
disk
);
extern
void
rand_initialize_disk
(
struct
gendisk
*
disk
);
...
...
include/linux/genhd.h
View file @
4d466c1f
...
...
@@ -63,6 +63,7 @@ struct hd_struct {
sector_t
nr_sects
;
devfs_handle_t
de
;
/* primary (master) devfs entry */
struct
device
*
hd_driverfs_dev
;
/* support driverfs hiearchy */
int
policy
;
};
#define GENHD_FL_REMOVABLE 1
...
...
@@ -94,7 +95,7 @@ struct gendisk {
struct
device
disk_dev
;
struct
timer_rand_state
*
random
;
int
policy
;
unsigned
sync_io
;
/* RAID */
unsigned
reads
,
writes
;
...
...
kernel/ksyms.c
View file @
4d466c1f
...
...
@@ -62,8 +62,6 @@
#include <linux/kmod.h>
#endif
extern
void
set_device_ro
(
kdev_t
dev
,
int
flag
);
extern
struct
timezone
sys_tz
;
#ifdef CONFIG_MODVERSIONS
...
...
@@ -341,8 +339,6 @@ EXPORT_SYMBOL(tty_unregister_driver);
EXPORT_SYMBOL
(
tty_std_termios
);
/* block device driver support */
EXPORT_SYMBOL
(
bdev_read_only
);
EXPORT_SYMBOL
(
set_device_ro
);
EXPORT_SYMBOL
(
bmap
);
EXPORT_SYMBOL
(
blkdev_open
);
EXPORT_SYMBOL
(
blkdev_get
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment