Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libtcg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anton
libtcg
Commits
6dd2db52
Commit
6dd2db52
authored
16 years ago
by
Blue Swirl
Browse files
Options
Downloads
Patches
Plain Diff
Revert 4367
git-svn-id:
svn://svn.savannah.nongnu.org/qemu/trunk@4377
c046a42c-6fe2-441c-8c8c-71466251a162
parent
dceaf394
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
block-raw-posix.c
+6
-113
6 additions, 113 deletions
block-raw-posix.c
with
6 additions
and
113 deletions
block-raw-posix.c
+
6
−
113
View file @
6dd2db52
...
...
@@ -77,10 +77,10 @@
typedef
struct
BDRVRawState
{
int
fd
;
int
type
;
int
open_flags
;
unsigned
int
lseek_err_cnt
;
#if defined(__linux__)
/* linux floppy specific */
int
fd_open_flags
;
int64_t
fd_open_time
;
int64_t
fd_error_time
;
int
fd_got_error
;
...
...
@@ -111,7 +111,6 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
open_flags
|=
O_DIRECT
;
#endif
s
->
open_flags
=
open_flags
;
s
->
type
=
FTYPE_FILE
;
fd
=
open
(
filename
,
open_flags
,
0644
);
...
...
@@ -142,14 +141,7 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
#endif
*/
/*
* offset and count are in bytes, but must be multiples of 512 for files
* opened with O_DIRECT. buf must be aligned to 512 bytes then.
*
* This function may be called without alignment if the caller ensures
* that O_DIRECT is not in effect.
*/
static
int
raw_pread_aligned
(
BlockDriverState
*
bs
,
int64_t
offset
,
static
int
raw_pread
(
BlockDriverState
*
bs
,
int64_t
offset
,
uint8_t
*
buf
,
int
count
)
{
BDRVRawState
*
s
=
bs
->
opaque
;
...
...
@@ -202,14 +194,7 @@ label__raw_read__success:
return
ret
;
}
/*
* offset and count are in bytes, but must be multiples of 512 for files
* opened with O_DIRECT. buf must be aligned to 512 bytes then.
*
* This function may be called without alignment if the caller ensures
* that O_DIRECT is not in effect.
*/
static
int
raw_pwrite_aligned
(
BlockDriverState
*
bs
,
int64_t
offset
,
static
int
raw_pwrite
(
BlockDriverState
*
bs
,
int64_t
offset
,
const
uint8_t
*
buf
,
int
count
)
{
BDRVRawState
*
s
=
bs
->
opaque
;
...
...
@@ -245,67 +230,6 @@ label__raw_write__success:
return
ret
;
}
#ifdef O_DIRECT
/*
* offset and count are in bytes and possibly not aligned. For files opened
* with O_DIRECT, necessary alignments are ensured before calling
* raw_pread_aligned to do the actual read.
*/
static
int
raw_pread
(
BlockDriverState
*
bs
,
int64_t
offset
,
uint8_t
*
buf
,
int
count
)
{
BDRVRawState
*
s
=
bs
->
opaque
;
if
(
unlikely
((
s
->
open_flags
&
O_DIRECT
)
&&
(
offset
%
512
||
count
%
512
||
(
uintptr_t
)
buf
%
512
)))
{
int
ret
;
// Temporarily disable O_DIRECT for unaligned access
fcntl
(
s
->
fd
,
F_SETFL
,
s
->
open_flags
&
~
O_DIRECT
);
ret
=
raw_pread_aligned
(
bs
,
offset
,
buf
,
count
);
fcntl
(
s
->
fd
,
F_SETFL
,
s
->
open_flags
);
return
ret
;
}
else
{
return
raw_pread_aligned
(
bs
,
offset
,
buf
,
count
);
}
}
/*
* offset and count are in bytes and possibly not aligned. For files opened
* with O_DIRECT, necessary alignments are ensured before calling
* raw_pwrite_aligned to do the actual write.
*/
static
int
raw_pwrite
(
BlockDriverState
*
bs
,
int64_t
offset
,
const
uint8_t
*
buf
,
int
count
)
{
BDRVRawState
*
s
=
bs
->
opaque
;
if
(
unlikely
((
s
->
open_flags
&
O_DIRECT
)
&&
(
offset
%
512
||
count
%
512
||
(
uintptr_t
)
buf
%
512
)))
{
int
ret
;
// Temporarily disable O_DIRECT for unaligned access
fcntl
(
s
->
fd
,
F_SETFL
,
s
->
open_flags
&
~
O_DIRECT
);
ret
=
raw_pwrite_aligned
(
bs
,
offset
,
buf
,
count
);
fcntl
(
s
->
fd
,
F_SETFL
,
s
->
open_flags
);
return
ret
;
}
else
{
return
raw_pwrite_aligned
(
bs
,
offset
,
buf
,
count
);
}
}
#else
#define raw_pread raw_pread_aligned
#define raw_pwrite raw_pwrite_aligned
#endif
/***********************************************************/
/* Unix AIO using POSIX AIO */
...
...
@@ -478,26 +402,10 @@ static BlockDriverAIOCB *raw_aio_read(BlockDriverState *bs,
BlockDriverCompletionFunc
*
cb
,
void
*
opaque
)
{
RawAIOCB
*
acb
;
BDRVRawState
*
s
=
bs
->
opaque
;
/*
* If O_DIRECT is used and the buffer is not aligned fall back
* to synchronous IO.
*/
if
(
unlikely
((
s
->
open_flags
&
O_DIRECT
)
&&
((
uintptr_t
)
buf
%
512
)))
{
int
ret
;
acb
=
qemu_aio_get
(
bs
,
cb
,
opaque
);
ret
=
raw_pread
(
bs
,
512
*
sector_num
,
buf
,
512
*
nb_sectors
);
acb
->
common
.
cb
(
acb
->
common
.
opaque
,
ret
);
qemu_aio_release
(
acb
);
return
&
acb
->
common
;
}
acb
=
raw_aio_setup
(
bs
,
sector_num
,
buf
,
nb_sectors
,
cb
,
opaque
);
if
(
!
acb
)
return
NULL
;
if
(
aio_read
(
&
acb
->
aiocb
)
<
0
)
{
qemu_aio_release
(
acb
);
return
NULL
;
...
...
@@ -510,21 +418,6 @@ static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs,
BlockDriverCompletionFunc
*
cb
,
void
*
opaque
)
{
RawAIOCB
*
acb
;
BDRVRawState
*
s
=
bs
->
opaque
;
/*
* If O_DIRECT is used and the buffer is not aligned fall back
* to synchronous IO.
*/
if
(
unlikely
((
s
->
open_flags
&
O_DIRECT
)
&&
((
uintptr_t
)
buf
%
512
)))
{
int
ret
;
acb
=
qemu_aio_get
(
bs
,
cb
,
opaque
);
ret
=
raw_pwrite
(
bs
,
512
*
sector_num
,
buf
,
512
*
nb_sectors
);
acb
->
common
.
cb
(
acb
->
common
.
opaque
,
ret
);
qemu_aio_release
(
acb
);
return
&
acb
->
common
;
}
acb
=
raw_aio_setup
(
bs
,
sector_num
,
(
uint8_t
*
)
buf
,
nb_sectors
,
cb
,
opaque
);
if
(
!
acb
)
...
...
@@ -786,7 +679,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
s
->
type
=
FTYPE_CD
;
}
else
if
(
strstart
(
filename
,
"/dev/fd"
,
NULL
))
{
s
->
type
=
FTYPE_FD
;
s
->
open_flags
=
open_flags
;
s
->
fd_
open_flags
=
open_flags
;
/* open will not fail even if no floppy is inserted */
open_flags
|=
O_NONBLOCK
;
}
else
if
(
strstart
(
filename
,
"/dev/sg"
,
NULL
))
{
...
...
@@ -841,7 +734,7 @@ static int fd_open(BlockDriverState *bs)
#endif
return
-
EIO
;
}
s
->
fd
=
open
(
bs
->
filename
,
s
->
open_flags
);
s
->
fd
=
open
(
bs
->
filename
,
s
->
fd_
open_flags
);
if
(
s
->
fd
<
0
)
{
s
->
fd_error_time
=
qemu_get_clock
(
rt_clock
);
s
->
fd_got_error
=
1
;
...
...
@@ -938,7 +831,7 @@ static int raw_eject(BlockDriverState *bs, int eject_flag)
close
(
s
->
fd
);
s
->
fd
=
-
1
;
}
fd
=
open
(
bs
->
filename
,
s
->
open_flags
|
O_NONBLOCK
);
fd
=
open
(
bs
->
filename
,
s
->
fd_
open_flags
|
O_NONBLOCK
);
if
(
fd
>=
0
)
{
if
(
ioctl
(
fd
,
FDEJECT
,
0
)
<
0
)
perror
(
"FDEJECT"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment