diff options
-rw-r--r-- | fs/ocfs2/dir.c | 43 | ||||
-rw-r--r-- | fs/ocfs2/inode.c | 50 | ||||
-rw-r--r-- | fs/ocfs2/inode.h | 2 |
3 files changed, 43 insertions, 52 deletions
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index 459e6b8467dc..ef2bb856f731 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
@@ -82,6 +82,49 @@ static int ocfs2_do_extend_dir(struct super_block *sb, | |||
82 | struct ocfs2_alloc_context *meta_ac, | 82 | struct ocfs2_alloc_context *meta_ac, |
83 | struct buffer_head **new_bh); | 83 | struct buffer_head **new_bh); |
84 | 84 | ||
85 | static struct buffer_head *ocfs2_bread(struct inode *inode, | ||
86 | int block, int *err, int reada) | ||
87 | { | ||
88 | struct buffer_head *bh = NULL; | ||
89 | int tmperr; | ||
90 | u64 p_blkno; | ||
91 | int readflags = OCFS2_BH_CACHED; | ||
92 | |||
93 | if (reada) | ||
94 | readflags |= OCFS2_BH_READAHEAD; | ||
95 | |||
96 | if (((u64)block << inode->i_sb->s_blocksize_bits) >= | ||
97 | i_size_read(inode)) { | ||
98 | BUG_ON(!reada); | ||
99 | return NULL; | ||
100 | } | ||
101 | |||
102 | down_read(&OCFS2_I(inode)->ip_alloc_sem); | ||
103 | tmperr = ocfs2_extent_map_get_blocks(inode, block, &p_blkno, NULL, | ||
104 | NULL); | ||
105 | up_read(&OCFS2_I(inode)->ip_alloc_sem); | ||
106 | if (tmperr < 0) { | ||
107 | mlog_errno(tmperr); | ||
108 | goto fail; | ||
109 | } | ||
110 | |||
111 | tmperr = ocfs2_read_blocks(inode, p_blkno, 1, &bh, readflags); | ||
112 | if (tmperr < 0) | ||
113 | goto fail; | ||
114 | |||
115 | tmperr = 0; | ||
116 | |||
117 | *err = 0; | ||
118 | return bh; | ||
119 | |||
120 | fail: | ||
121 | brelse(bh); | ||
122 | bh = NULL; | ||
123 | |||
124 | *err = -EIO; | ||
125 | return NULL; | ||
126 | } | ||
127 | |||
85 | /* | 128 | /* |
86 | * bh passed here can be an inode block or a dir data block, depending | 129 | * bh passed here can be an inode block or a dir data block, depending |
87 | * on the inode inline data flag. | 130 | * on the inode inline data flag. |
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index c5ee9e3cf80b..8381c26b21a8 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c | |||
@@ -1133,56 +1133,6 @@ void ocfs2_drop_inode(struct inode *inode) | |||
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | /* | 1135 | /* |
1136 | * TODO: this should probably be merged into ocfs2_get_block | ||
1137 | * | ||
1138 | * However, you now need to pay attention to the cont_prepare_write() | ||
1139 | * stuff in ocfs2_get_block (that is, ocfs2_get_block pretty much | ||
1140 | * expects never to extend). | ||
1141 | */ | ||
1142 | struct buffer_head *ocfs2_bread(struct inode *inode, | ||
1143 | int block, int *err, int reada) | ||
1144 | { | ||
1145 | struct buffer_head *bh = NULL; | ||
1146 | int tmperr; | ||
1147 | u64 p_blkno; | ||
1148 | int readflags = OCFS2_BH_CACHED; | ||
1149 | |||
1150 | if (reada) | ||
1151 | readflags |= OCFS2_BH_READAHEAD; | ||
1152 | |||
1153 | if (((u64)block << inode->i_sb->s_blocksize_bits) >= | ||
1154 | i_size_read(inode)) { | ||
1155 | BUG_ON(!reada); | ||
1156 | return NULL; | ||
1157 | } | ||
1158 | |||
1159 | down_read(&OCFS2_I(inode)->ip_alloc_sem); | ||
1160 | tmperr = ocfs2_extent_map_get_blocks(inode, block, &p_blkno, NULL, | ||
1161 | NULL); | ||
1162 | up_read(&OCFS2_I(inode)->ip_alloc_sem); | ||
1163 | if (tmperr < 0) { | ||
1164 | mlog_errno(tmperr); | ||
1165 | goto fail; | ||
1166 | } | ||
1167 | |||
1168 | tmperr = ocfs2_read_blocks(inode, p_blkno, 1, &bh, readflags); | ||
1169 | if (tmperr < 0) | ||
1170 | goto fail; | ||
1171 | |||
1172 | tmperr = 0; | ||
1173 | |||
1174 | *err = 0; | ||
1175 | return bh; | ||
1176 | |||
1177 | fail: | ||
1178 | brelse(bh); | ||
1179 | bh = NULL; | ||
1180 | |||
1181 | *err = -EIO; | ||
1182 | return NULL; | ||
1183 | } | ||
1184 | |||
1185 | /* | ||
1186 | * This is called from our getattr. | 1136 | * This is called from our getattr. |
1187 | */ | 1137 | */ |
1188 | int ocfs2_inode_revalidate(struct dentry *dentry) | 1138 | int ocfs2_inode_revalidate(struct dentry *dentry) |
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h index f66e4340f178..2f37af9bcc4a 100644 --- a/fs/ocfs2/inode.h +++ b/fs/ocfs2/inode.h | |||
@@ -117,8 +117,6 @@ extern struct kmem_cache *ocfs2_inode_cache; | |||
117 | 117 | ||
118 | extern const struct address_space_operations ocfs2_aops; | 118 | extern const struct address_space_operations ocfs2_aops; |
119 | 119 | ||
120 | struct buffer_head *ocfs2_bread(struct inode *inode, int block, | ||
121 | int *err, int reada); | ||
122 | void ocfs2_clear_inode(struct inode *inode); | 120 | void ocfs2_clear_inode(struct inode *inode); |
123 | void ocfs2_delete_inode(struct inode *inode); | 121 | void ocfs2_delete_inode(struct inode *inode); |
124 | void ocfs2_drop_inode(struct inode *inode); | 122 | void ocfs2_drop_inode(struct inode *inode); |