From patchwork Wed Apr 12 03:45:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 9676433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F0C0560382 for ; Wed, 12 Apr 2017 03:45:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEE4E28545 for ; Wed, 12 Apr 2017 03:45:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3E4A28573; Wed, 12 Apr 2017 03:45:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 019BF28545 for ; Wed, 12 Apr 2017 03:45:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752089AbdDLDp3 (ORCPT ); Tue, 11 Apr 2017 23:45:29 -0400 Received: from sandeen.net ([63.231.237.45]:40052 "EHLO sandeen.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752072AbdDLDp2 (ORCPT ); Tue, 11 Apr 2017 23:45:28 -0400 Received: from [10.0.0.4] (liberator [10.0.0.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sandeen.net (Postfix) with ESMTPSA id 1FBB958DC1E; Tue, 11 Apr 2017 22:45:28 -0500 (CDT) Subject: [PATCH] xfs_db: allow write -d to dqblks To: "Darrick J. Wong" , Eric Sandeen References: <20170411225334.GE8502@birch.djwong.org> Cc: xfs From: Eric Sandeen Message-ID: <4e5eaa1f-b551-885b-6d1c-e90f985496be@sandeen.net> Date: Tue, 11 Apr 2017 22:45:27 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170411225334.GE8502@birch.djwong.org> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow write -d to write bad data and recalculate CRC for dqblks. Inspired-by: Darrick J. Wong Signed-off-by: Eric Sandeen Reviewed-by: Darrick J. Wong --- -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/db/io.c b/db/io.c index 67ed5f9..9918a51 100644 --- a/db/io.c +++ b/db/io.c @@ -476,6 +476,17 @@ xfs_verify_recalc_inode_crc( } void +xfs_verify_recalc_dquot_crc( + struct xfs_buf *bp) +{ + ASSERT((iocur_top->dquot_buf)); + ASSERT(iocur_top->bp == bp); + + xfs_update_cksum(iocur_top->data, sizeof(struct xfs_dqblk), + XFS_DQUOT_CRC_OFF); +} + +void xfs_verify_recalc_crc( struct xfs_buf *bp) { diff --git a/db/io.h b/db/io.h index 12d96c2..b415b82 100644 --- a/db/io.h +++ b/db/io.h @@ -65,6 +65,7 @@ extern void ring_add(void); extern void set_iocur_type(const struct typ *t); extern void xfs_dummy_verify(struct xfs_buf *bp); extern void xfs_verify_recalc_inode_crc(struct xfs_buf *bp); +extern void xfs_verify_recalc_dquot_crc(struct xfs_buf *bp); extern void xfs_verify_recalc_crc(struct xfs_buf *bp); /* diff --git a/db/write.c b/db/write.c index 70c9865..d24ea05 100644 --- a/db/write.c +++ b/db/write.c @@ -139,7 +139,8 @@ write_f( if (invalid_data && iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF && - !iocur_top->ino_buf) { + !iocur_top->ino_buf && + !iocur_top->dquot_buf) { dbprintf(_("Cannot recalculate CRCs on this type of object\n")); return 0; } @@ -169,6 +170,9 @@ write_f( } else if (iocur_top->ino_buf) { local_ops.verify_write = xfs_verify_recalc_inode_crc; dbprintf(_("Allowing write of corrupted inode with good CRC\n")); + } else if (iocur_top->dquot_buf) { + local_ops.verify_write = xfs_verify_recalc_dquot_crc; + dbprintf(_("Allowing write of corrupted dquot with good CRC\n")); } else { /* invalid data */ local_ops.verify_write = xfs_verify_recalc_crc; dbprintf(_("Allowing write of corrupted data with good CRC\n"));