Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linux
linux-davinci
Commits
c90eef84
Commit
c90eef84
authored
Sep 20, 2005
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Plain Diff
Merge master.kernel.org:/pub/scm/linux/kernel/git/aia21/ntfs-2.6
parents
9600c11b
eed8b2de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
22 deletions
+33
-22
fs/ntfs/runlist.c
fs/ntfs/runlist.c
+33
-22
No files found.
fs/ntfs/runlist.c
View file @
c90eef84
...
@@ -158,17 +158,21 @@ static inline BOOL ntfs_are_rl_mergeable(runlist_element *dst,
...
@@ -158,17 +158,21 @@ static inline BOOL ntfs_are_rl_mergeable(runlist_element *dst,
BUG_ON
(
!
dst
);
BUG_ON
(
!
dst
);
BUG_ON
(
!
src
);
BUG_ON
(
!
src
);
if
((
dst
->
lcn
<
0
)
||
(
src
->
lcn
<
0
))
{
/* Are we merging holes? */
/* We can merge unmapped regions even if they are misaligned. */
if
(
dst
->
lcn
==
LCN_HOLE
&&
src
->
lcn
==
LCN_HOLE
)
if
((
dst
->
lcn
==
LCN_RL_NOT_MAPPED
)
&&
(
src
->
lcn
==
LCN_RL_NOT_MAPPED
))
return
TRUE
;
return
TRUE
;
/* If the runs are misaligned, we cannot merge them. */
if
((
dst
->
vcn
+
dst
->
length
)
!=
src
->
vcn
)
return
FALSE
;
return
FALSE
;
}
/* If both runs are non-sparse and contiguous, we can merge them. */
if
((
dst
->
lcn
+
dst
->
length
)
!=
src
->
lcn
)
/* Are the runs contiguous? */
if
((
dst
->
lcn
>=
0
)
&&
(
src
->
lcn
>=
0
)
&&
return
FALSE
;
((
dst
->
lcn
+
dst
->
length
)
==
src
->
lcn
))
if
((
dst
->
vcn
+
dst
->
length
)
!=
src
->
vcn
)
/* Are the runs misaligned? */
return
TRUE
;
return
FALSE
;
/* If we are merging two holes, we can merge them. */
if
((
dst
->
lcn
==
LCN_HOLE
)
&&
(
src
->
lcn
==
LCN_HOLE
))
return
TRUE
;
return
TRUE
;
/* Cannot merge. */
return
FALSE
;
}
}
/**
/**
...
@@ -214,14 +218,15 @@ static inline void __ntfs_rl_merge(runlist_element *dst, runlist_element *src)
...
@@ -214,14 +218,15 @@ static inline void __ntfs_rl_merge(runlist_element *dst, runlist_element *src)
static
inline
runlist_element
*
ntfs_rl_append
(
runlist_element
*
dst
,
static
inline
runlist_element
*
ntfs_rl_append
(
runlist_element
*
dst
,
int
dsize
,
runlist_element
*
src
,
int
ssize
,
int
loc
)
int
dsize
,
runlist_element
*
src
,
int
ssize
,
int
loc
)
{
{
BOOL
right
;
/* Right end of @src needs merging. */
BOOL
right
=
FALSE
;
/* Right end of @src needs merging. */
int
marker
;
/* End of the inserted runs. */
int
marker
;
/* End of the inserted runs. */
BUG_ON
(
!
dst
);
BUG_ON
(
!
dst
);
BUG_ON
(
!
src
);
BUG_ON
(
!
src
);
/* First, check if the right hand end needs merging. */
/* First, check if the right hand end needs merging. */
right
=
ntfs_are_rl_mergeable
(
src
+
ssize
-
1
,
dst
+
loc
+
1
);
if
((
loc
+
1
)
<
dsize
)
right
=
ntfs_are_rl_mergeable
(
src
+
ssize
-
1
,
dst
+
loc
+
1
);
/* Space required: @dst size + @src size, less one if we merged. */
/* Space required: @dst size + @src size, less one if we merged. */
dst
=
ntfs_rl_realloc
(
dst
,
dsize
,
dsize
+
ssize
-
right
);
dst
=
ntfs_rl_realloc
(
dst
,
dsize
,
dsize
+
ssize
-
right
);
...
@@ -377,20 +382,21 @@ static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
...
@@ -377,20 +382,21 @@ static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
int
dsize
,
runlist_element
*
src
,
int
ssize
,
int
loc
)
int
dsize
,
runlist_element
*
src
,
int
ssize
,
int
loc
)
{
{
BOOL
left
=
FALSE
;
/* Left end of @src needs merging. */
BOOL
left
=
FALSE
;
/* Left end of @src needs merging. */
BOOL
right
;
/* Right end of @src needs merging. */
BOOL
right
=
FALSE
;
/* Right end of @src needs merging. */
int
tail
;
/* Start of tail of @dst. */
int
tail
;
/* Start of tail of @dst. */
int
marker
;
/* End of the inserted runs. */
int
marker
;
/* End of the inserted runs. */
BUG_ON
(
!
dst
);
BUG_ON
(
!
dst
);
BUG_ON
(
!
src
);
BUG_ON
(
!
src
);
/* First, merge the left and right ends, if necessary. */
/* First, see if the left and right ends need merging. */
right
=
ntfs_are_rl_mergeable
(
src
+
ssize
-
1
,
dst
+
loc
+
1
);
if
((
loc
+
1
)
<
dsize
)
right
=
ntfs_are_rl_mergeable
(
src
+
ssize
-
1
,
dst
+
loc
+
1
);
if
(
loc
>
0
)
if
(
loc
>
0
)
left
=
ntfs_are_rl_mergeable
(
dst
+
loc
-
1
,
src
);
left
=
ntfs_are_rl_mergeable
(
dst
+
loc
-
1
,
src
);
/*
/*
* Allocate some space. We will need less if the left, right, or both
* Allocate some space. We will need less if the left, right, or both
* ends
were
merged.
* ends
get
merged.
*/
*/
dst
=
ntfs_rl_realloc
(
dst
,
dsize
,
dsize
+
ssize
-
left
-
right
);
dst
=
ntfs_rl_realloc
(
dst
,
dsize
,
dsize
+
ssize
-
left
-
right
);
if
(
IS_ERR
(
dst
))
if
(
IS_ERR
(
dst
))
...
@@ -399,21 +405,26 @@ static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
...
@@ -399,21 +405,26 @@ static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
* We are guaranteed to succeed from here so can start modifying the
* We are guaranteed to succeed from here so can start modifying the
* original runlists.
* original runlists.
*/
*/
/* First, merge the left and right ends, if necessary. */
if
(
right
)
if
(
right
)
__ntfs_rl_merge
(
src
+
ssize
-
1
,
dst
+
loc
+
1
);
__ntfs_rl_merge
(
src
+
ssize
-
1
,
dst
+
loc
+
1
);
if
(
left
)
if
(
left
)
__ntfs_rl_merge
(
dst
+
loc
-
1
,
src
);
__ntfs_rl_merge
(
dst
+
loc
-
1
,
src
);
/*
/*
* First run of @dst that needs to be moved out of the way to make
* Offset of the tail of @dst. This needs to be moved out of the way
* space for the runs to be copied from @src, i.e. the first run of the
* to make space for the runs to be copied from @src, i.e. the first
* tail of @dst.
* run of the tail of @dst.
* Nominally, @tail equals @loc + 1, i.e. location, skipping the
* replaced run. However, if @right, then one of @dst's runs is
* already merged into @src.
*/
*/
tail
=
loc
+
right
+
1
;
tail
=
loc
+
right
+
1
;
/*
/*
* First run after the @src runs that have been inserted, i.e. where
* First run after the @src runs that have been inserted, i.e. where
* the tail of @dst needs to be moved to.
* the tail of @dst needs to be moved to.
* Nominally, marker equals @loc + @ssize, i.e. location + number of
* Nominally,
@
marker equals @loc + @ssize, i.e. location + number of
* runs in @src
)
. However, if @left, then the first run in @src has
* runs in @src. However, if @left, then the first run in @src has
* been merged with one in @dst.
* been merged with one in @dst.
*/
*/
marker
=
loc
+
ssize
-
left
;
marker
=
loc
+
ssize
-
left
;
...
...
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