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
nexedi
linux
Commits
1c215028
Commit
1c215028
authored
Aug 29, 2014
by
Theodore Ts'o
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ext4: convert ext4_bread() to use the ERR_PTR convention
Signed-off-by:
Theodore Ts'o
<
tytso@mit.edu
>
parent
10560082
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
43 deletions
+34
-43
fs/ext4/dir.c
fs/ext4/dir.c
+3
-5
fs/ext4/ext4.h
fs/ext4/ext4.h
+1
-2
fs/ext4/inode.c
fs/ext4/inode.c
+4
-10
fs/ext4/namei.c
fs/ext4/namei.c
+18
-16
fs/ext4/super.c
fs/ext4/super.c
+8
-10
No files found.
fs/ext4/dir.c
View file @
1c215028
...
@@ -151,13 +151,11 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
...
@@ -151,13 +151,11 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
&
file
->
f_ra
,
file
,
&
file
->
f_ra
,
file
,
index
,
1
);
index
,
1
);
file
->
f_ra
.
prev_pos
=
(
loff_t
)
index
<<
PAGE_CACHE_SHIFT
;
file
->
f_ra
.
prev_pos
=
(
loff_t
)
index
<<
PAGE_CACHE_SHIFT
;
bh
=
ext4_bread
(
NULL
,
inode
,
map
.
m_lblk
,
0
,
&
err
);
bh
=
ext4_bread
(
NULL
,
inode
,
map
.
m_lblk
,
0
);
if
(
IS_ERR
(
bh
))
return
PTR_ERR
(
bh
);
}
}
/*
* We ignore I/O errors on directories so users have a chance
* of recovering data when there's a bad sector
*/
if
(
!
bh
)
{
if
(
!
bh
)
{
if
(
!
dir_has_error
)
{
if
(
!
dir_has_error
)
{
EXT4_ERROR_FILE
(
file
,
0
,
EXT4_ERROR_FILE
(
file
,
0
,
...
...
fs/ext4/ext4.h
View file @
1c215028
...
@@ -2087,8 +2087,7 @@ extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
...
@@ -2087,8 +2087,7 @@ extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
/* inode.c */
/* inode.c */
struct
buffer_head
*
ext4_getblk
(
handle_t
*
,
struct
inode
*
,
ext4_lblk_t
,
int
);
struct
buffer_head
*
ext4_getblk
(
handle_t
*
,
struct
inode
*
,
ext4_lblk_t
,
int
);
struct
buffer_head
*
ext4_bread
(
handle_t
*
,
struct
inode
*
,
struct
buffer_head
*
ext4_bread
(
handle_t
*
,
struct
inode
*
,
ext4_lblk_t
,
int
);
ext4_lblk_t
,
int
,
int
*
);
int
ext4_get_block_write
(
struct
inode
*
inode
,
sector_t
iblock
,
int
ext4_get_block_write
(
struct
inode
*
inode
,
sector_t
iblock
,
struct
buffer_head
*
bh_result
,
int
create
);
struct
buffer_head
*
bh_result
,
int
create
);
int
ext4_get_block
(
struct
inode
*
inode
,
sector_t
iblock
,
int
ext4_get_block
(
struct
inode
*
inode
,
sector_t
iblock
,
...
...
fs/ext4/inode.c
View file @
1c215028
...
@@ -791,27 +791,21 @@ struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode,
...
@@ -791,27 +791,21 @@ struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode,
}
}
struct
buffer_head
*
ext4_bread
(
handle_t
*
handle
,
struct
inode
*
inode
,
struct
buffer_head
*
ext4_bread
(
handle_t
*
handle
,
struct
inode
*
inode
,
ext4_lblk_t
block
,
int
create
,
int
*
err
)
ext4_lblk_t
block
,
int
create
)
{
{
struct
buffer_head
*
bh
;
struct
buffer_head
*
bh
;
*
err
=
0
;
bh
=
ext4_getblk
(
handle
,
inode
,
block
,
create
);
bh
=
ext4_getblk
(
handle
,
inode
,
block
,
create
);
if
(
IS_ERR
(
bh
))
{
if
(
IS_ERR
(
bh
))
*
err
=
PTR_ERR
(
bh
);
return
NULL
;
}
if
(
!
bh
)
return
bh
;
return
bh
;
if
(
buffer_uptodate
(
bh
))
if
(
!
bh
||
buffer_uptodate
(
bh
))
return
bh
;
return
bh
;
ll_rw_block
(
READ
|
REQ_META
|
REQ_PRIO
,
1
,
&
bh
);
ll_rw_block
(
READ
|
REQ_META
|
REQ_PRIO
,
1
,
&
bh
);
wait_on_buffer
(
bh
);
wait_on_buffer
(
bh
);
if
(
buffer_uptodate
(
bh
))
if
(
buffer_uptodate
(
bh
))
return
bh
;
return
bh
;
put_bh
(
bh
);
put_bh
(
bh
);
*
err
=
-
EIO
;
return
ERR_PTR
(
-
EIO
);
return
NULL
;
}
}
int
ext4_walk_page_buffers
(
handle_t
*
handle
,
int
ext4_walk_page_buffers
(
handle_t
*
handle
,
...
...
fs/ext4/namei.c
View file @
1c215028
...
@@ -53,7 +53,7 @@ static struct buffer_head *ext4_append(handle_t *handle,
...
@@ -53,7 +53,7 @@ static struct buffer_head *ext4_append(handle_t *handle,
ext4_lblk_t
*
block
)
ext4_lblk_t
*
block
)
{
{
struct
buffer_head
*
bh
;
struct
buffer_head
*
bh
;
int
err
=
0
;
int
err
;
if
(
unlikely
(
EXT4_SB
(
inode
->
i_sb
)
->
s_max_dir_size_kb
&&
if
(
unlikely
(
EXT4_SB
(
inode
->
i_sb
)
->
s_max_dir_size_kb
&&
((
inode
->
i_size
>>
10
)
>=
((
inode
->
i_size
>>
10
)
>=
...
@@ -62,9 +62,9 @@ static struct buffer_head *ext4_append(handle_t *handle,
...
@@ -62,9 +62,9 @@ static struct buffer_head *ext4_append(handle_t *handle,
*
block
=
inode
->
i_size
>>
inode
->
i_sb
->
s_blocksize_bits
;
*
block
=
inode
->
i_size
>>
inode
->
i_sb
->
s_blocksize_bits
;
bh
=
ext4_bread
(
handle
,
inode
,
*
block
,
1
,
&
err
);
bh
=
ext4_bread
(
handle
,
inode
,
*
block
,
1
);
if
(
!
bh
)
if
(
IS_ERR
(
bh
)
)
return
ERR_PTR
(
err
)
;
return
bh
;
inode
->
i_size
+=
inode
->
i_sb
->
s_blocksize
;
inode
->
i_size
+=
inode
->
i_sb
->
s_blocksize
;
EXT4_I
(
inode
)
->
i_disksize
=
inode
->
i_size
;
EXT4_I
(
inode
)
->
i_disksize
=
inode
->
i_size
;
BUFFER_TRACE
(
bh
,
"get_write_access"
);
BUFFER_TRACE
(
bh
,
"get_write_access"
);
...
@@ -94,20 +94,20 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
...
@@ -94,20 +94,20 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
{
{
struct
buffer_head
*
bh
;
struct
buffer_head
*
bh
;
struct
ext4_dir_entry
*
dirent
;
struct
ext4_dir_entry
*
dirent
;
int
err
=
0
,
is_dx_block
=
0
;
int
is_dx_block
=
0
;
bh
=
ext4_bread
(
NULL
,
inode
,
block
,
0
,
&
err
);
bh
=
ext4_bread
(
NULL
,
inode
,
block
,
0
);
if
(
!
bh
)
{
if
(
IS_ERR
(
bh
))
{
if
(
err
==
0
)
{
ext4_error_inode
(
inode
,
__func__
,
line
,
block
,
"Directory hole found"
);
return
ERR_PTR
(
-
EIO
);
}
__ext4_warning
(
inode
->
i_sb
,
__func__
,
line
,
__ext4_warning
(
inode
->
i_sb
,
__func__
,
line
,
"error reading directory block "
"error
%ld
reading directory block "
"(ino %lu, block %lu)"
,
inode
->
i_ino
,
"(ino %lu, block %lu)"
,
PTR_ERR
(
bh
),
inode
->
i_ino
,
(
unsigned
long
)
block
);
(
unsigned
long
)
block
);
return
ERR_PTR
(
err
);
return
bh
;
}
if
(
!
bh
)
{
ext4_error_inode
(
inode
,
__func__
,
line
,
block
,
"Directory hole found"
);
return
ERR_PTR
(
-
EIO
);
}
}
dirent
=
(
struct
ext4_dir_entry
*
)
bh
->
b_data
;
dirent
=
(
struct
ext4_dir_entry
*
)
bh
->
b_data
;
/* Determine whether or not we have an index block */
/* Determine whether or not we have an index block */
...
@@ -640,7 +640,9 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
...
@@ -640,7 +640,9 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
u32
range
=
i
<
count
-
1
?
(
dx_get_hash
(
entries
+
1
)
-
hash
)
:
~
hash
;
u32
range
=
i
<
count
-
1
?
(
dx_get_hash
(
entries
+
1
)
-
hash
)
:
~
hash
;
struct
stats
stats
;
struct
stats
stats
;
printk
(
"%s%3u:%03u hash %8x/%8x "
,
levels
?
""
:
" "
,
i
,
block
,
hash
,
range
);
printk
(
"%s%3u:%03u hash %8x/%8x "
,
levels
?
""
:
" "
,
i
,
block
,
hash
,
range
);
if
(
!
(
bh
=
ext4_bread
(
NULL
,
dir
,
block
,
0
,
&
err
)))
continue
;
bh
=
ext4_bread
(
NULL
,
dir
,
block
,
0
);
if
(
!
bh
||
IS_ERR
(
bh
))
continue
;
stats
=
levels
?
stats
=
levels
?
dx_show_entries
(
hinfo
,
dir
,
((
struct
dx_node
*
)
bh
->
b_data
)
->
entries
,
levels
-
1
)
:
dx_show_entries
(
hinfo
,
dir
,
((
struct
dx_node
*
)
bh
->
b_data
)
->
entries
,
levels
-
1
)
:
dx_show_leaf
(
hinfo
,
(
struct
ext4_dir_entry_2
*
)
bh
->
b_data
,
blocksize
,
0
);
dx_show_leaf
(
hinfo
,
(
struct
ext4_dir_entry_2
*
)
bh
->
b_data
,
blocksize
,
0
);
...
...
fs/ext4/super.c
View file @
1c215028
...
@@ -5305,7 +5305,6 @@ static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
...
@@ -5305,7 +5305,6 @@ static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
{
{
struct
inode
*
inode
=
sb_dqopt
(
sb
)
->
files
[
type
];
struct
inode
*
inode
=
sb_dqopt
(
sb
)
->
files
[
type
];
ext4_lblk_t
blk
=
off
>>
EXT4_BLOCK_SIZE_BITS
(
sb
);
ext4_lblk_t
blk
=
off
>>
EXT4_BLOCK_SIZE_BITS
(
sb
);
int
err
=
0
;
int
offset
=
off
&
(
sb
->
s_blocksize
-
1
);
int
offset
=
off
&
(
sb
->
s_blocksize
-
1
);
int
tocopy
;
int
tocopy
;
size_t
toread
;
size_t
toread
;
...
@@ -5320,9 +5319,9 @@ static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
...
@@ -5320,9 +5319,9 @@ static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
while
(
toread
>
0
)
{
while
(
toread
>
0
)
{
tocopy
=
sb
->
s_blocksize
-
offset
<
toread
?
tocopy
=
sb
->
s_blocksize
-
offset
<
toread
?
sb
->
s_blocksize
-
offset
:
toread
;
sb
->
s_blocksize
-
offset
:
toread
;
bh
=
ext4_bread
(
NULL
,
inode
,
blk
,
0
,
&
err
);
bh
=
ext4_bread
(
NULL
,
inode
,
blk
,
0
);
if
(
err
)
if
(
IS_ERR
(
bh
)
)
return
err
;
return
PTR_ERR
(
bh
)
;
if
(
!
bh
)
/* A hole? */
if
(
!
bh
)
/* A hole? */
memset
(
data
,
0
,
tocopy
);
memset
(
data
,
0
,
tocopy
);
else
else
...
@@ -5343,8 +5342,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
...
@@ -5343,8 +5342,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
{
{
struct
inode
*
inode
=
sb_dqopt
(
sb
)
->
files
[
type
];
struct
inode
*
inode
=
sb_dqopt
(
sb
)
->
files
[
type
];
ext4_lblk_t
blk
=
off
>>
EXT4_BLOCK_SIZE_BITS
(
sb
);
ext4_lblk_t
blk
=
off
>>
EXT4_BLOCK_SIZE_BITS
(
sb
);
int
err
=
0
;
int
err
,
offset
=
off
&
(
sb
->
s_blocksize
-
1
);
int
offset
=
off
&
(
sb
->
s_blocksize
-
1
);
struct
buffer_head
*
bh
;
struct
buffer_head
*
bh
;
handle_t
*
handle
=
journal_current_handle
();
handle_t
*
handle
=
journal_current_handle
();
...
@@ -5365,14 +5363,16 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
...
@@ -5365,14 +5363,16 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
return
-
EIO
;
return
-
EIO
;
}
}
bh
=
ext4_bread
(
handle
,
inode
,
blk
,
1
,
&
err
);
bh
=
ext4_bread
(
handle
,
inode
,
blk
,
1
);
if
(
IS_ERR
(
bh
))
return
PTR_ERR
(
bh
);
if
(
!
bh
)
if
(
!
bh
)
goto
out
;
goto
out
;
BUFFER_TRACE
(
bh
,
"get write access"
);
BUFFER_TRACE
(
bh
,
"get write access"
);
err
=
ext4_journal_get_write_access
(
handle
,
bh
);
err
=
ext4_journal_get_write_access
(
handle
,
bh
);
if
(
err
)
{
if
(
err
)
{
brelse
(
bh
);
brelse
(
bh
);
goto
out
;
return
err
;
}
}
lock_buffer
(
bh
);
lock_buffer
(
bh
);
memcpy
(
bh
->
b_data
+
offset
,
data
,
len
);
memcpy
(
bh
->
b_data
+
offset
,
data
,
len
);
...
@@ -5381,8 +5381,6 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
...
@@ -5381,8 +5381,6 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
err
=
ext4_handle_dirty_metadata
(
handle
,
NULL
,
bh
);
err
=
ext4_handle_dirty_metadata
(
handle
,
NULL
,
bh
);
brelse
(
bh
);
brelse
(
bh
);
out:
out:
if
(
err
)
return
err
;
if
(
inode
->
i_size
<
off
+
len
)
{
if
(
inode
->
i_size
<
off
+
len
)
{
i_size_write
(
inode
,
off
+
len
);
i_size_write
(
inode
,
off
+
len
);
EXT4_I
(
inode
)
->
i_disksize
=
inode
->
i_size
;
EXT4_I
(
inode
)
->
i_disksize
=
inode
->
i_size
;
...
...
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