diff options
author | Joseph Qi <joseph.qi@huawei.com> | 2015-02-16 19:00:15 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-16 20:56:05 -0500 |
commit | 160cc266639d4213c15c103074561c1b44ffe691 (patch) | |
tree | 5994c8a38cb2f52b7cad048a3827aac9015fe28f /fs/ocfs2 | |
parent | 4813962beef7586f890a645a1bda77691da4b74a (diff) |
ocfs2: set append dio as a ro compat feature
Intruduce a bit OCFS2_FEATURE_RO_COMPAT_APPEND_DIO and check it in
write flow. If the bit is not set, fall back to the old way.
Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Weiwei Wang <wangww631@huawei.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Xuejiufei <xuejiufei@huawei.com>
Cc: alex chen <alex.chen@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/file.c | 17 | ||||
-rw-r--r-- | fs/ocfs2/ocfs2.h | 8 | ||||
-rw-r--r-- | fs/ocfs2/ocfs2_fs.h | 8 |
3 files changed, 31 insertions, 2 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 784f2c72c992..46e0d4e857c7 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -2213,6 +2213,15 @@ static int ocfs2_prepare_inode_for_write(struct file *file, | |||
2213 | } | 2213 | } |
2214 | 2214 | ||
2215 | /* | 2215 | /* |
2216 | * Fallback to old way if the feature bit is not set. | ||
2217 | */ | ||
2218 | if (end > i_size_read(inode) && | ||
2219 | !ocfs2_supports_append_dio(osb)) { | ||
2220 | *direct_io = 0; | ||
2221 | break; | ||
2222 | } | ||
2223 | |||
2224 | /* | ||
2216 | * We don't fill holes during direct io, so | 2225 | * We don't fill holes during direct io, so |
2217 | * check for them here. If any are found, the | 2226 | * check for them here. If any are found, the |
2218 | * caller will have to retake some cluster | 2227 | * caller will have to retake some cluster |
@@ -2220,7 +2229,13 @@ static int ocfs2_prepare_inode_for_write(struct file *file, | |||
2220 | */ | 2229 | */ |
2221 | ret = ocfs2_check_range_for_holes(inode, saved_pos, count); | 2230 | ret = ocfs2_check_range_for_holes(inode, saved_pos, count); |
2222 | if (ret == 1) { | 2231 | if (ret == 1) { |
2223 | *direct_io = 0; | 2232 | /* |
2233 | * Fallback to old way if the feature bit is not set. | ||
2234 | * Otherwise try dio first and then complete the rest | ||
2235 | * request through buffer io. | ||
2236 | */ | ||
2237 | if (!ocfs2_supports_append_dio(osb)) | ||
2238 | *direct_io = 0; | ||
2224 | ret = 0; | 2239 | ret = 0; |
2225 | } else if (ret < 0) | 2240 | } else if (ret < 0) |
2226 | mlog_errno(ret); | 2241 | mlog_errno(ret); |
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 7e39cd654834..8490c64d34fe 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
@@ -500,6 +500,14 @@ static inline int ocfs2_writes_unwritten_extents(struct ocfs2_super *osb) | |||
500 | return 0; | 500 | return 0; |
501 | } | 501 | } |
502 | 502 | ||
503 | static inline int ocfs2_supports_append_dio(struct ocfs2_super *osb) | ||
504 | { | ||
505 | if (osb->s_feature_ro_compat & OCFS2_FEATURE_RO_COMPAT_APPEND_DIO) | ||
506 | return 1; | ||
507 | return 0; | ||
508 | } | ||
509 | |||
510 | |||
503 | static inline int ocfs2_supports_inline_data(struct ocfs2_super *osb) | 511 | static inline int ocfs2_supports_inline_data(struct ocfs2_super *osb) |
504 | { | 512 | { |
505 | if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_INLINE_DATA) | 513 | if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_INLINE_DATA) |
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index cf4fa43af78e..20e37a3ed26f 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h | |||
@@ -105,7 +105,8 @@ | |||
105 | | OCFS2_FEATURE_INCOMPAT_CLUSTERINFO) | 105 | | OCFS2_FEATURE_INCOMPAT_CLUSTERINFO) |
106 | #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \ | 106 | #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \ |
107 | | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \ | 107 | | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \ |
108 | | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA) | 108 | | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA \ |
109 | | OCFS2_FEATURE_RO_COMPAT_APPEND_DIO) | ||
109 | 110 | ||
110 | /* | 111 | /* |
111 | * Heartbeat-only devices are missing journals and other files. The | 112 | * Heartbeat-only devices are missing journals and other files. The |
@@ -199,6 +200,11 @@ | |||
199 | #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002 | 200 | #define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002 |
200 | #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004 | 201 | #define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004 |
201 | 202 | ||
203 | /* | ||
204 | * Append Direct IO support | ||
205 | */ | ||
206 | #define OCFS2_FEATURE_RO_COMPAT_APPEND_DIO 0x0008 | ||
207 | |||
202 | /* The byte offset of the first backup block will be 1G. | 208 | /* The byte offset of the first backup block will be 1G. |
203 | * The following will be 4G, 16G, 64G, 256G and 1T. | 209 | * The following will be 4G, 16G, 64G, 256G and 1T. |
204 | */ | 210 | */ |