From patchwork Mon Feb 2 02:59:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Qi X-Patchwork-Id: 5758901 Return-Path: X-Original-To: patchwork-ocfs2-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4A170BF440 for ; Mon, 2 Feb 2015 03:00:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7722420260 for ; Mon, 2 Feb 2015 03:00:54 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 58F4920218 for ; Mon, 2 Feb 2015 03:00:53 +0000 (UTC) Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t1230AGe004543 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 2 Feb 2015 03:00:11 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id t12309j0011431 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 2 Feb 2015 03:00:10 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1YI7FB-0008M9-Oy; Sun, 01 Feb 2015 19:00:09 -0800 Received: from acsinet21.oracle.com ([141.146.126.237]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1YI7F9-0008Lw-D9; Sun, 01 Feb 2015 19:00:07 -0800 Received: from aserp1060.oracle.com (aserp1060.oracle.com [141.146.126.71]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t12306SU017166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 2 Feb 2015 03:00:07 GMT Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by aserp1060.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t12305jY003629 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 2 Feb 2015 03:00:06 GMT Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.14.7/8.14.7) with SMTP id t122xOG2013341; Mon, 2 Feb 2015 03:00:05 GMT Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [119.145.14.66]) by userp2030.oracle.com with ESMTP id 1s9uatuv6w-1 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT); Mon, 02 Feb 2015 03:00:05 +0000 Received: from 172.24.2.119 (EHLO szxeml434-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BBG51583; Mon, 02 Feb 2015 11:00:02 +0800 (CST) Received: from [127.0.0.1] (10.177.24.125) by szxeml434-hub.china.huawei.com (10.82.67.225) with Microsoft SMTP Server id 14.3.158.1; Mon, 2 Feb 2015 10:59:58 +0800 Message-ID: <54CEE82D.5040609@huawei.com> Date: Mon, 2 Feb 2015 10:59:57 +0800 From: Joseph Qi User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: "ocfs2-devel@oss.oracle.com" , X-Originating-IP: [10.177.24.125] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.54CEE832.003B, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 8584a705762119d90df0d3a62399080c X-ServerName: szxga03-in.huawei.com X-Proofpoint-Virus-Version: vendor=nai engine=5600 definitions=7699 signatures=670623 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=2 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1502020032 Subject: [Ocfs2-devel] [PATCH 3/3] fsck.ocfs2: support append direct io ro compat feature X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Support to truncate direct io orphan entry in fsck.ocfs2. Signed-off-by: Joseph Qi --- fsck.ocfs2/pass4.c | 9 +++++++++ libocfs2/truncate.c | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/fsck.ocfs2/pass4.c b/fsck.ocfs2/pass4.c index 7737cc9..de3f672 100644 --- a/fsck.ocfs2/pass4.c +++ b/fsck.ocfs2/pass4.c @@ -100,6 +100,9 @@ out: return; } +#define OCFS2_DIO_ORPHAN_PREFIX "dio-" +#define OCFS2_DIO_ORPHAN_PREFIX_LEN 4 + static int replay_orphan_iterate(struct ocfs2_dir_entry *dirent, uint64_t blocknr, int offset, @@ -138,6 +141,11 @@ static int replay_orphan_iterate(struct ocfs2_dir_entry *dirent, goto out; } + /* do not delete inode in case of dio orphan entry */ + if (!strncmp(dirent->name, OCFS2_DIO_ORPHAN_PREFIX, + OCFS2_DIO_ORPHAN_PREFIX_LEN)) + goto out_check; + ret = ocfs2_delete_inode(ost->ost_fs, dirent->inode); if (ret) { com_err(whoami, ret, "while deleting orphan inode %"PRIu64 @@ -148,6 +156,7 @@ static int replay_orphan_iterate(struct ocfs2_dir_entry *dirent, ost->ost_orphan_deleted_count++; +out_check: /* Only calculate icount in force check. */ if (ost->ost_force) { /* diff --git a/libocfs2/truncate.c b/libocfs2/truncate.c index 7327253..451db28 100644 --- a/libocfs2/truncate.c +++ b/libocfs2/truncate.c @@ -33,6 +33,7 @@ #include #include #include "ocfs2/ocfs2.h" +#include "ocfs2/byteorder.h" struct truncate_ctxt { uint64_t ino; @@ -356,6 +357,16 @@ errcode_t ocfs2_truncate_full(ocfs2_filesys *fs, uint64_t ino, if (ret) goto out; + /* in case of dio crashed, force do trucate since blocks may already + * be allocated + */ + if (ci->ci_inode->i_flags & cpu_to_le32(OCFS2_DIO_ORPHANED_FL)) { + ci->ci_inode->i_flags &= ~cpu_to_le32(OCFS2_DIO_ORPHANED_FL); + ci->ci_inode->i_dio_orphaned_slot = 0; + new_i_size = ci->ci_inode->i_size; + goto truncate; + } + if (ci->ci_inode->i_size == new_i_size) goto out; @@ -364,6 +375,7 @@ errcode_t ocfs2_truncate_full(ocfs2_filesys *fs, uint64_t ino, goto out; } +truncate: if ((S_ISLNK(ci->ci_inode->i_mode) && !ci->ci_inode->i_clusters) || (ci->ci_inode->i_dyn_features & OCFS2_INLINE_DATA_FL)) ret = ocfs2_truncate_inline(fs, ino, new_i_size);