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
b0c68f8b
Commit
b0c68f8b
authored
Jan 31, 2008
by
Chris Mason
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Btrfs: Enable delalloc accounting
Signed-off-by:
Chris Mason
<
chris.mason@oracle.com
>
parent
0181e58f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
14 deletions
+26
-14
fs/btrfs/disk-io.c
fs/btrfs/disk-io.c
+4
-0
fs/btrfs/extent_io.c
fs/btrfs/extent_io.c
+7
-7
fs/btrfs/extent_io.h
fs/btrfs/extent_io.h
+2
-2
fs/btrfs/inode.c
fs/btrfs/inode.c
+13
-5
No files found.
fs/btrfs/disk-io.c
View file @
b0c68f8b
...
@@ -861,6 +861,10 @@ int close_ctree(struct btrfs_root *root)
...
@@ -861,6 +861,10 @@ int close_ctree(struct btrfs_root *root)
write_ctree_super
(
NULL
,
root
);
write_ctree_super
(
NULL
,
root
);
mutex_unlock
(
&
fs_info
->
fs_mutex
);
mutex_unlock
(
&
fs_info
->
fs_mutex
);
if
(
fs_info
->
delalloc_bytes
)
{
printk
(
"btrfs: at unmount delalloc count %Lu
\n
"
,
fs_info
->
delalloc_bytes
);
}
if
(
fs_info
->
extent_root
->
node
)
if
(
fs_info
->
extent_root
->
node
)
free_extent_buffer
(
fs_info
->
extent_root
->
node
);
free_extent_buffer
(
fs_info
->
extent_root
->
node
);
...
...
fs/btrfs/extent_io.c
View file @
b0c68f8b
...
@@ -262,7 +262,7 @@ static void set_state_cb(struct extent_io_tree *tree,
...
@@ -262,7 +262,7 @@ static void set_state_cb(struct extent_io_tree *tree,
{
{
if
(
tree
->
ops
&&
tree
->
ops
->
set_bit_hook
)
{
if
(
tree
->
ops
&&
tree
->
ops
->
set_bit_hook
)
{
tree
->
ops
->
set_bit_hook
(
tree
->
mapping
->
host
,
state
->
start
,
tree
->
ops
->
set_bit_hook
(
tree
->
mapping
->
host
,
state
->
start
,
state
->
end
,
bits
);
state
->
end
,
state
->
state
,
bits
);
}
}
}
}
...
@@ -272,7 +272,7 @@ static void clear_state_cb(struct extent_io_tree *tree,
...
@@ -272,7 +272,7 @@ static void clear_state_cb(struct extent_io_tree *tree,
{
{
if
(
tree
->
ops
&&
tree
->
ops
->
set_bit_hook
)
{
if
(
tree
->
ops
&&
tree
->
ops
->
set_bit_hook
)
{
tree
->
ops
->
clear_bit_hook
(
tree
->
mapping
->
host
,
state
->
start
,
tree
->
ops
->
clear_bit_hook
(
tree
->
mapping
->
host
,
state
->
start
,
state
->
end
,
bits
);
state
->
end
,
state
->
state
,
bits
);
}
}
}
}
...
@@ -298,10 +298,10 @@ static int insert_state(struct extent_io_tree *tree,
...
@@ -298,10 +298,10 @@ static int insert_state(struct extent_io_tree *tree,
}
}
if
(
bits
&
EXTENT_DIRTY
)
if
(
bits
&
EXTENT_DIRTY
)
tree
->
dirty_bytes
+=
end
-
start
+
1
;
tree
->
dirty_bytes
+=
end
-
start
+
1
;
set_state_cb
(
tree
,
state
,
bits
);
state
->
state
|=
bits
;
state
->
state
|=
bits
;
state
->
start
=
start
;
state
->
start
=
start
;
state
->
end
=
end
;
state
->
end
=
end
;
set_state_cb
(
tree
,
state
,
bits
);
node
=
tree_insert
(
&
tree
->
state
,
end
,
&
state
->
rb_node
);
node
=
tree_insert
(
&
tree
->
state
,
end
,
&
state
->
rb_node
);
if
(
node
)
{
if
(
node
)
{
struct
extent_state
*
found
;
struct
extent_state
*
found
;
...
@@ -369,8 +369,8 @@ static int clear_state_bit(struct extent_io_tree *tree,
...
@@ -369,8 +369,8 @@ static int clear_state_bit(struct extent_io_tree *tree,
WARN_ON
(
range
>
tree
->
dirty_bytes
);
WARN_ON
(
range
>
tree
->
dirty_bytes
);
tree
->
dirty_bytes
-=
range
;
tree
->
dirty_bytes
-=
range
;
}
}
state
->
state
&=
~
bits
;
clear_state_cb
(
tree
,
state
,
bits
);
clear_state_cb
(
tree
,
state
,
bits
);
state
->
state
&=
~
bits
;
if
(
wake
)
if
(
wake
)
wake_up
(
&
state
->
wq
);
wake_up
(
&
state
->
wq
);
if
(
delete
||
state
->
state
==
0
)
{
if
(
delete
||
state
->
state
==
0
)
{
...
@@ -574,8 +574,8 @@ static void set_state_bits(struct extent_io_tree *tree,
...
@@ -574,8 +574,8 @@ static void set_state_bits(struct extent_io_tree *tree,
u64
range
=
state
->
end
-
state
->
start
+
1
;
u64
range
=
state
->
end
-
state
->
start
+
1
;
tree
->
dirty_bytes
+=
range
;
tree
->
dirty_bytes
+=
range
;
}
}
state
->
state
|=
bits
;
set_state_cb
(
tree
,
state
,
bits
);
set_state_cb
(
tree
,
state
,
bits
);
state
->
state
|=
bits
;
}
}
/*
/*
...
@@ -997,8 +997,8 @@ search_again:
...
@@ -997,8 +997,8 @@ search_again:
free_extent_state
(
state
);
free_extent_state
(
state
);
goto
search_again
;
goto
search_again
;
}
}
state
->
state
|=
EXTENT_LOCKED
;
set_state_cb
(
tree
,
state
,
EXTENT_LOCKED
);
set_state_cb
(
tree
,
state
,
EXTENT_LOCKED
);
state
->
state
|=
EXTENT_LOCKED
;
if
(
!
found
)
if
(
!
found
)
*
start
=
state
->
start
;
*
start
=
state
->
start
;
found
++
;
found
++
;
...
@@ -1497,8 +1497,8 @@ static int end_bio_extent_readpage(struct bio *bio,
...
@@ -1497,8 +1497,8 @@ static int end_bio_extent_readpage(struct bio *bio,
}
else
{
}
else
{
state
=
NULL
;
state
=
NULL
;
}
}
clear
->
state
|=
EXTENT_UPTODATE
;
set_state_cb
(
tree
,
clear
,
EXTENT_UPTODATE
);
set_state_cb
(
tree
,
clear
,
EXTENT_UPTODATE
);
clear
->
state
|=
EXTENT_UPTODATE
;
clear_state_bit
(
tree
,
clear
,
EXTENT_LOCKED
,
clear_state_bit
(
tree
,
clear
,
EXTENT_LOCKED
,
1
,
0
);
1
,
0
);
if
(
cur
==
start
)
if
(
cur
==
start
)
...
...
fs/btrfs/extent_io.h
View file @
b0c68f8b
...
@@ -34,9 +34,9 @@ struct extent_io_ops {
...
@@ -34,9 +34,9 @@ struct extent_io_ops {
void
(
*
writepage_end_io_hook
)(
struct
page
*
page
,
u64
start
,
u64
end
,
void
(
*
writepage_end_io_hook
)(
struct
page
*
page
,
u64
start
,
u64
end
,
struct
extent_state
*
state
);
struct
extent_state
*
state
);
int
(
*
set_bit_hook
)(
struct
inode
*
inode
,
u64
start
,
u64
end
,
int
(
*
set_bit_hook
)(
struct
inode
*
inode
,
u64
start
,
u64
end
,
unsigned
long
bits
);
unsigned
long
old
,
unsigned
long
bits
);
int
(
*
clear_bit_hook
)(
struct
inode
*
inode
,
u64
start
,
u64
end
,
int
(
*
clear_bit_hook
)(
struct
inode
*
inode
,
u64
start
,
u64
end
,
unsigned
long
bits
);
unsigned
long
old
,
unsigned
long
bits
);
};
};
struct
extent_io_tree
{
struct
extent_io_tree
{
...
...
fs/btrfs/inode.c
View file @
b0c68f8b
...
@@ -260,9 +260,9 @@ static int run_delalloc_range(struct inode *inode, u64 start, u64 end)
...
@@ -260,9 +260,9 @@ static int run_delalloc_range(struct inode *inode, u64 start, u64 end)
}
}
int
btrfs_set_bit_hook
(
struct
inode
*
inode
,
u64
start
,
u64
end
,
int
btrfs_set_bit_hook
(
struct
inode
*
inode
,
u64
start
,
u64
end
,
unsigned
long
bits
)
unsigned
long
old
,
unsigned
long
bits
)
{
{
if
((
bits
&
EXTENT_DELALLOC
))
{
if
(
!
(
old
&
EXTENT_DELALLOC
)
&&
(
bits
&
EXTENT_DELALLOC
))
{
struct
btrfs_root
*
root
=
BTRFS_I
(
inode
)
->
root
;
struct
btrfs_root
*
root
=
BTRFS_I
(
inode
)
->
root
;
spin_lock
(
&
root
->
fs_info
->
delalloc_lock
);
spin_lock
(
&
root
->
fs_info
->
delalloc_lock
);
root
->
fs_info
->
delalloc_bytes
+=
end
-
start
+
1
;
root
->
fs_info
->
delalloc_bytes
+=
end
-
start
+
1
;
...
@@ -272,12 +272,18 @@ int btrfs_set_bit_hook(struct inode *inode, u64 start, u64 end,
...
@@ -272,12 +272,18 @@ int btrfs_set_bit_hook(struct inode *inode, u64 start, u64 end,
}
}
int
btrfs_clear_bit_hook
(
struct
inode
*
inode
,
u64
start
,
u64
end
,
int
btrfs_clear_bit_hook
(
struct
inode
*
inode
,
u64
start
,
u64
end
,
unsigned
long
bits
)
unsigned
long
old
,
unsigned
long
bits
)
{
{
if
((
bits
&
EXTENT_DELALLOC
))
{
if
((
old
&
EXTENT_DELALLOC
)
&&
(
bits
&
EXTENT_DELALLOC
))
{
struct
btrfs_root
*
root
=
BTRFS_I
(
inode
)
->
root
;
struct
btrfs_root
*
root
=
BTRFS_I
(
inode
)
->
root
;
spin_lock
(
&
root
->
fs_info
->
delalloc_lock
);
spin_lock
(
&
root
->
fs_info
->
delalloc_lock
);
if
(
end
-
start
+
1
>
root
->
fs_info
->
delalloc_bytes
)
{
printk
(
"warning: delalloc account %Lu %Lu
\n
"
,
end
-
start
+
1
,
root
->
fs_info
->
delalloc_bytes
);
root
->
fs_info
->
delalloc_bytes
=
0
;
}
else
{
root
->
fs_info
->
delalloc_bytes
-=
end
-
start
+
1
;
root
->
fs_info
->
delalloc_bytes
-=
end
-
start
+
1
;
}
spin_unlock
(
&
root
->
fs_info
->
delalloc_lock
);
spin_unlock
(
&
root
->
fs_info
->
delalloc_lock
);
}
}
return
0
;
return
0
;
...
@@ -3002,6 +3008,8 @@ static struct extent_io_ops btrfs_extent_io_ops = {
...
@@ -3002,6 +3008,8 @@ static struct extent_io_ops btrfs_extent_io_ops = {
.
writepage_io_hook
=
btrfs_writepage_io_hook
,
.
writepage_io_hook
=
btrfs_writepage_io_hook
,
.
readpage_io_hook
=
btrfs_readpage_io_hook
,
.
readpage_io_hook
=
btrfs_readpage_io_hook
,
.
readpage_end_io_hook
=
btrfs_readpage_end_io_hook
,
.
readpage_end_io_hook
=
btrfs_readpage_end_io_hook
,
.
set_bit_hook
=
btrfs_set_bit_hook
,
.
clear_bit_hook
=
btrfs_clear_bit_hook
,
};
};
static
struct
address_space_operations
btrfs_aops
=
{
static
struct
address_space_operations
btrfs_aops
=
{
...
...
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