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
624a75e8
Commit
624a75e8
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] rd
* switched to private queues * set ->queue * cleaned up
parent
7bc7ae9e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
69 deletions
+37
-69
drivers/block/rd.c
drivers/block/rd.c
+37
-69
No files found.
drivers/block/rd.c
View file @
624a75e8
...
@@ -77,7 +77,6 @@ int initrd_below_start_ok;
...
@@ -77,7 +77,6 @@ int initrd_below_start_ok;
/* Various static variables go here. Most are used only in the RAM disk code.
/* Various static variables go here. Most are used only in the RAM disk code.
*/
*/
static
unsigned
long
rd_length
[
NUM_RAMDISKS
];
/* Size of RAM disks in bytes */
static
struct
gendisk
*
rd_disks
[
NUM_RAMDISKS
];
static
struct
gendisk
*
rd_disks
[
NUM_RAMDISKS
];
static
devfs_handle_t
devfs_handle
;
static
devfs_handle_t
devfs_handle
;
static
struct
block_device
*
rd_bdev
[
NUM_RAMDISKS
];
/* Protected device data */
static
struct
block_device
*
rd_bdev
[
NUM_RAMDISKS
];
/* Protected device data */
...
@@ -147,21 +146,14 @@ static struct address_space_operations ramdisk_aops = {
...
@@ -147,21 +146,14 @@ static struct address_space_operations ramdisk_aops = {
commit_write:
ramdisk_commit_write
,
commit_write:
ramdisk_commit_write
,
};
};
static
int
rd_blkdev_pagecache_IO
(
int
rw
,
struct
bio_vec
*
vec
,
static
int
rd_blkdev_pagecache_IO
(
int
rw
,
struct
bio_vec
*
vec
,
sector_t
sector
,
sector_t
sector
,
int
minor
)
struct
address_space
*
mapping
)
{
{
struct
address_space
*
mapping
;
unsigned
long
index
=
sector
>>
(
PAGE_CACHE_SHIFT
-
9
);
unsigned
long
index
;
unsigned
int
vec_offset
=
vec
->
bv_offset
;
unsigned
int
vec_offset
;
int
offset
=
(
sector
<<
9
)
&
~
PAGE_CACHE_MASK
;
int
offset
,
size
,
err
;
int
size
=
vec
->
bv_len
;
int
err
=
0
;
err
=
0
;
mapping
=
rd_bdev
[
minor
]
->
bd_inode
->
i_mapping
;
index
=
sector
>>
(
PAGE_CACHE_SHIFT
-
9
);
offset
=
(
sector
<<
9
)
&
~
PAGE_CACHE_MASK
;
size
=
vec
->
bv_len
;
vec_offset
=
vec
->
bv_offset
;
do
{
do
{
int
count
;
int
count
;
...
@@ -197,12 +189,10 @@ static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec,
...
@@ -197,12 +189,10 @@ static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec,
index
++
;
index
++
;
if
(
rw
==
READ
)
{
if
(
rw
==
READ
)
{
src
=
kmap
(
page
);
src
=
kmap
(
page
)
+
offset
;
src
+=
offset
;
dst
=
kmap
(
vec
->
bv_page
)
+
vec_offset
;
dst
=
kmap
(
vec
->
bv_page
)
+
vec_offset
;
}
else
{
}
else
{
dst
=
kmap
(
page
);
dst
=
kmap
(
page
)
+
offset
;
dst
+=
offset
;
src
=
kmap
(
vec
->
bv_page
)
+
vec_offset
;
src
=
kmap
(
vec
->
bv_page
)
+
vec_offset
;
}
}
offset
=
0
;
offset
=
0
;
...
@@ -227,22 +217,6 @@ static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec,
...
@@ -227,22 +217,6 @@ static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec,
return
err
;
return
err
;
}
}
static
int
rd_blkdev_bio_IO
(
struct
bio
*
bio
,
unsigned
int
minor
)
{
struct
bio_vec
*
bvec
;
sector_t
sector
;
int
ret
=
0
,
i
,
rw
;
sector
=
bio
->
bi_sector
;
rw
=
bio_data_dir
(
bio
);
bio_for_each_segment
(
bvec
,
bio
,
i
)
{
ret
|=
rd_blkdev_pagecache_IO
(
rw
,
bvec
,
sector
,
minor
);
sector
+=
bvec
->
bv_len
>>
9
;
}
return
ret
;
}
/*
/*
* Basically, my strategy here is to set up a buffer-head which can't be
* Basically, my strategy here is to set up a buffer-head which can't be
* deleted, and make that my Ramdisk. If the request is outside of the
* deleted, and make that my Ramdisk. If the request is outside of the
...
@@ -251,37 +225,33 @@ static int rd_blkdev_bio_IO(struct bio *bio, unsigned int minor)
...
@@ -251,37 +225,33 @@ static int rd_blkdev_bio_IO(struct bio *bio, unsigned int minor)
* 19-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Added devfs support
* 19-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Added devfs support
*
*
*/
*/
static
int
rd_make_request
(
request_queue_t
*
q
,
struct
bio
*
sbh
)
static
int
rd_make_request
(
request_queue_t
*
q
,
struct
bio
*
bio
)
{
{
unsigned
int
minor
;
struct
block_device
*
bdev
=
bio
->
bi_bdev
;
unsigned
long
offset
,
len
;
struct
address_space
*
mapping
=
bdev
->
bd_inode
->
i_mapping
;
int
rw
=
sbh
->
bi_rw
;
sector_t
sector
=
bio
->
bi_sector
;
unsigned
long
len
=
bio
->
bi_size
>>
9
;
minor
=
minor
(
to_kdev_t
(
sbh
->
bi_bdev
->
bd_dev
));
int
rw
=
bio_data_dir
(
bio
);
struct
bio_vec
*
bvec
;
if
(
minor
>=
NUM_RAMDISKS
)
int
ret
=
0
,
i
;
goto
fail
;
offset
=
sbh
->
bi_sector
<<
9
;
len
=
sbh
->
bi_size
;
if
(
(
offset
+
len
)
>
rd_length
[
minor
]
)
if
(
sector
+
len
>
get_capacity
(
bdev
->
bd_disk
)
)
goto
fail
;
goto
fail
;
if
(
rw
==
READA
)
if
(
rw
==
READA
)
rw
=
READ
;
rw
=
READ
;
if
((
rw
!=
READ
)
&&
(
rw
!=
WRITE
))
{
printk
(
KERN_INFO
"RAMDISK: bad command: %d
\n
"
,
rw
);
goto
fail
;
}
if
(
rd_blkdev_bio_IO
(
sbh
,
minor
))
bio_for_each_segment
(
bvec
,
bio
,
i
)
{
ret
|=
rd_blkdev_pagecache_IO
(
rw
,
bvec
,
sector
,
mapping
);
sector
+=
bvec
->
bv_len
>>
9
;
}
if
(
ret
)
goto
fail
;
goto
fail
;
bio_endio
(
sbh
,
sbh
->
bi_size
,
0
);
bio_endio
(
bio
,
bio
->
bi_size
,
0
);
return
0
;
return
0
;
fail:
fail:
bio_io_error
(
sbh
,
sbh
->
bi_size
);
bio_io_error
(
bio
,
bio
->
bi_size
);
return
0
;
return
0
;
}
}
...
@@ -373,21 +343,18 @@ static int rd_open(struct inode * inode, struct file * filp)
...
@@ -373,21 +343,18 @@ static int rd_open(struct inode * inode, struct file * filp)
}
}
#endif
#endif
if
(
unit
>=
NUM_RAMDISKS
)
return
-
ENXIO
;
/*
/*
* Immunize device against invalidate_buffers() and prune_icache().
* Immunize device against invalidate_buffers() and prune_icache().
*/
*/
if
(
rd_bdev
[
unit
]
==
NULL
)
{
if
(
rd_bdev
[
unit
]
==
NULL
)
{
rd_bdev
[
unit
]
=
bdget
(
kdev_t_to_nr
(
inode
->
i_rdev
))
;
struct
block_device
*
bdev
=
inode
->
i_bdev
;
rd_bdev
[
unit
]
->
bd_openers
++
;
rd_bdev
[
unit
]
=
bdev
;
rd_bdev
[
unit
]
->
bd_block_size
=
rd_blocksize
;
bdev
->
bd_openers
++
;
rd_bdev
[
unit
]
->
bd_inode
->
i_mapping
->
a_ops
=
&
ramdisk_aops
;
bdev
->
bd_block_size
=
rd_blocksize
;
rd_bdev
[
unit
]
->
bd_inode
->
i_mapping
->
backing_dev_info
=
&
rd_backing_dev_info
;
inode
->
i_mapping
->
a_ops
=
&
ramdisk_aops
;
rd_bdev
[
unit
]
->
bd_inode
->
i_size
=
rd_length
[
unit
]
;
inode
->
i_mapping
->
backing_dev_info
=
&
rd_backing_dev_info
;
rd_bdev
[
unit
]
->
bd_queue
=
&
blk_dev
[
MAJOR_NR
].
request_queue
;
get_disk
(
bdev
->
bd_disk
)
;
rd_bdev
[
unit
]
->
bd_disk
=
get_disk
(
rd_disks
[
unit
])
;
bdev
->
bd_inode
->
i_size
=
get_capacity
(
bdev
->
bd_disk
)
<<
9
;
}
}
return
0
;
return
0
;
...
@@ -422,6 +389,7 @@ static void __exit rd_cleanup (void)
...
@@ -422,6 +389,7 @@ static void __exit rd_cleanup (void)
unregister_blkdev
(
MAJOR_NR
,
"ramdisk"
);
unregister_blkdev
(
MAJOR_NR
,
"ramdisk"
);
}
}
static
struct
request_queue
rd_queue
;
/* This is the registration and initialization section of the RAM disk driver */
/* This is the registration and initialization section of the RAM disk driver */
static
int
__init
rd_init
(
void
)
static
int
__init
rd_init
(
void
)
{
{
...
@@ -456,15 +424,15 @@ static int __init rd_init (void)
...
@@ -456,15 +424,15 @@ static int __init rd_init (void)
goto
out
;
goto
out
;
}
}
blk_queue_make_request
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
)
,
&
rd_make_request
);
blk_queue_make_request
(
&
rd_queue
,
&
rd_make_request
);
for
(
i
=
0
;
i
<
NUM_RAMDISKS
;
i
++
)
{
for
(
i
=
0
;
i
<
NUM_RAMDISKS
;
i
++
)
{
struct
gendisk
*
disk
=
rd_disks
[
i
];
struct
gendisk
*
disk
=
rd_disks
[
i
];
/* rd_size is given in kB */
/* rd_size is given in kB */
rd_length
[
i
]
=
rd_size
<<
10
;
disk
->
major
=
MAJOR_NR
;
disk
->
major
=
MAJOR_NR
;
disk
->
first_minor
=
i
;
disk
->
first_minor
=
i
;
disk
->
fops
=
&
rd_bd_op
;
disk
->
fops
=
&
rd_bd_op
;
disk
->
queue
=
&
rd_queue
;
sprintf
(
disk
->
disk_name
,
"rd%d"
,
i
);
sprintf
(
disk
->
disk_name
,
"rd%d"
,
i
);
set_capacity
(
disk
,
rd_size
*
2
);
set_capacity
(
disk
,
rd_size
*
2
);
}
}
...
...
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