* re: ext4: serialize unaligned asynchronous DIO
@ 2014-05-27 14:17 Dan Carpenter
2014-05-27 15:38 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2014-05-27 14:17 UTC (permalink / raw)
To: Namjae Jeon; +Cc: linux-ext4
Hello Namjae Jeon,
The patch 00532604c72e: "ext4: introduce new i_write_mutex to protect
fallocate" from May 26, 2014, leads to the following static checker
warning:
fs/ext4/file.c:195 ext4_file_write_iter()
warn: 'mutex:&EXT4_Iinode->i_write_mutex' is sometimes locked here and sometimes unlocked.
fs/ext4/file.c
104 mutex_lock(&EXT4_I(inode)->i_write_mutex);
105
106 /*
107 * Unaligned direct AIO must be serialized; see comment above
108 * In the case of O_APPEND, assume that we must always serialize
109 */
110 if (o_direct &&
111 ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS) &&
112 !is_sync_kiocb(iocb) &&
113 (file->f_flags & O_APPEND ||
114 ext4_unaligned_aio(inode, from, pos))) {
115 unaligned_direct_aio = true;
116 ext4_unwritten_wait(inode);
117 }
118
119 mutex_lock(&inode->i_mutex);
120 if (file->f_flags & O_APPEND)
121 iocb->ki_pos = pos = i_size_read(inode);
122
123 /*
124 * If we have encountered a bitmap-format file, the size limit
125 * is smaller than s_maxbytes, which is for extent-mapped files.
126 */
127 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
128 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
129
130 if ((pos > sbi->s_bitmap_maxbytes) ||
131 (pos == sbi->s_bitmap_maxbytes && length > 0)) {
132 mutex_unlock(&inode->i_mutex);
133 ret = -EFBIG;
We want to always unlock on this path but it only unlocks when
"unaligned_direct_aio" is true.
134 goto errout;
135 }
136
[ snip ]
192 errout:
193 if (unaligned_direct_aio)
194 mutex_unlock(&EXT4_I(inode)->i_write_mutex);
195 return ret;
196 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: ext4: serialize unaligned asynchronous DIO
2014-05-27 14:17 ext4: serialize unaligned asynchronous DIO Dan Carpenter
@ 2014-05-27 15:38 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2014-05-27 15:38 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Namjae Jeon, linux-ext4
On Tue, May 27, 2014 at 05:17:08PM +0300, Dan Carpenter wrote:
> Hello Namjae Jeon,
>
> The patch 00532604c72e: "ext4: introduce new i_write_mutex to protect
> fallocate" from May 26, 2014, leads to the following static checker
> warning:
Thanks, already fixed with the following incremental patch.
- Ted
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 8c39305..e5cd87f 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -135,8 +135,8 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
if ((pos > sbi->s_bitmap_maxbytes) ||
(pos == sbi->s_bitmap_maxbytes && length > 0)) {
mutex_unlock(&inode->i_mutex);
- ret = -EFBIG;
- goto errout;
+ mutex_unlock(&EXT4_I(inode)->i_write_mutex);
+ return -EFBIG;
}
if (pos + length > sbi->s_bitmap_maxbytes) {
@@ -196,7 +196,6 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
if (o_direct)
blk_finish_plug(&plug);
-errout:
if (unaligned_direct_aio)
mutex_unlock(&EXT4_I(inode)->i_write_mutex);
return ret;
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-27 15:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-27 14:17 ext4: serialize unaligned asynchronous DIO Dan Carpenter
2014-05-27 15:38 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).