From: Wengang Wang <wen.gang.wang@oracle.com>
To: ocfs2-devel@oss.oracle.com
Cc: wen.gang.wang@oracle.com, stable@vger.kernel.org,
gregkh@linuxfoundation.org, gechangwei@live.cn,
junxiao.bi@oracle.com, akpm@linux-foundation.org,
jiangqi903@gmail.com
Subject: [Ocfs2-devel] [PATCH V2] ocfs2: free up write context when direct IO failed
Date: Fri, 2 Nov 2018 10:06:32 -0700
Message-ID: <20181102170632.25921-1-wen.gang.wang@oracle.com> (raw)
The write context should also be freed even when direct IO failed.
Otherwise a memory leak is introduced and entries remain in
oi->ip_unwritten_list causing the following BUG later in unlink path:
ERROR: bug expression: !list_empty(&oi->ip_unwritten_list)
ERROR: Clear inode of 215043, inode has unwritten extents
...
Call Trace:
? __set_current_blocked+0x42/0x68
ocfs2_evict_inode+0x91/0x6a0 [ocfs2]
? bit_waitqueue+0x40/0x33
evict+0xdb/0x1af
iput+0x1a2/0x1f7
do_unlinkat+0x194/0x28f
SyS_unlinkat+0x1b/0x2f
do_syscall_64+0x79/0x1ae
entry_SYSCALL_64_after_hwframe+0x151/0x0
This patch also logs, with frequency limit, direct IO failures.
Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
---
v1 -> v2: log direct IO failures
---
fs/ocfs2/aops.c | 12 ++++++++++--
fs/ocfs2/cluster/masklog.h | 9 +++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 302cd7c..7578bd5 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -2412,8 +2412,16 @@ static int ocfs2_dio_end_io(struct kiocb *iocb,
/* this io's submitter should not have unlocked this before we could */
BUG_ON(!ocfs2_iocb_is_rw_locked(iocb));
- if (bytes > 0 && private)
- ret = ocfs2_dio_end_io_write(inode, private, offset, bytes);
+ if (bytes <= 0)
+ mlog_ratelimited(ML_ERROR, "Direct IO failed, bytes = %lld",
+ (long long)bytes);
+ if (private) {
+ if (bytes > 0)
+ ret = ocfs2_dio_end_io_write(inode, private, offset,
+ bytes);
+ else
+ ocfs2_dio_free_write_ctx(inode, private);
+ }
ocfs2_iocb_clear_rw_locked(iocb);
diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h
index 308ea0e..a396096 100644
--- a/fs/ocfs2/cluster/masklog.h
+++ b/fs/ocfs2/cluster/masklog.h
@@ -178,6 +178,15 @@ do { \
##__VA_ARGS__); \
} while (0)
+#define mlog_ratelimited(mask, fmt, ...) \
+do { \
+ static DEFINE_RATELIMIT_STATE(_rs, \
+ DEFAULT_RATELIMIT_INTERVAL, \
+ DEFAULT_RATELIMIT_BURST); \
+ if (__ratelimit(&_rs)) \
+ mlog(mask, fmt, ##__VA_ARGS__); \
+} while (0)
+
#define mlog_errno(st) ({ \
int _st = (st); \
if (_st != -ERESTARTSYS && _st != -EINTR && \
--
2.9.5
next reply index
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-02 17:06 Wengang Wang [this message]
2018-11-02 17:10 ` Wengang Wang
2018-11-03 6:44 ` Greg KH
2018-11-04 23:54 ` Junxiao Bi
2018-11-05 1:59 ` Changwei Ge
2018-11-05 2:05 ` Joseph Qi
2018-11-06 20:02 ` Wengang Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181102170632.25921-1-wen.gang.wang@oracle.com \
--to=wen.gang.wang@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=gechangwei@live.cn \
--cc=gregkh@linuxfoundation.org \
--cc=jiangqi903@gmail.com \
--cc=junxiao.bi@oracle.com \
--cc=ocfs2-devel@oss.oracle.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
OCFS2-Devel Archive on lore.kernel.org
Archives are clonable:
git clone --mirror https://lore.kernel.org/ocfs2-devel/0 ocfs2-devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ocfs2-devel ocfs2-devel/ https://lore.kernel.org/ocfs2-devel \
ocfs2-devel@oss.oracle.com
public-inbox-index ocfs2-devel
Example config snippet for mirrors
Newsgroup available over NNTP:
nntp://nntp.lore.kernel.org/com.oracle.oss.ocfs2-devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git