From patchwork Wed Feb 14 10:28:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 10218353 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 81782601C2 for ; Wed, 14 Feb 2018 10:29:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B28B28C3A for ; Wed, 14 Feb 2018 10:29:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FB3F28F55; Wed, 14 Feb 2018 10:29:02 +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 1B29C28C3A for ; Wed, 14 Feb 2018 10:29:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967161AbeBNK27 (ORCPT ); Wed, 14 Feb 2018 05:28:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:60029 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966997AbeBNK26 (ORCPT ); Wed, 14 Feb 2018 05:28:58 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1238EAE95; Wed, 14 Feb 2018 10:28:57 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id B86E71E04F1; Wed, 14 Feb 2018 11:28:56 +0100 (CET) From: Jan Kara To: Cc: =?UTF-8?q?Pali=20Roh=C3=A1r?= , Jan Kara Subject: [PATCH 5/6] udf: Unify common handling of descriptors Date: Wed, 14 Feb 2018 11:28:49 +0100 Message-Id: <20180214102850.28755-6-jack@suse.cz> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180214102850.28755-1-jack@suse.cz> References: <20180214102850.28755-1-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When scanning Volume Descriptor Sequence, several descriptors have exactly the same handling. Unify it. Signed-off-by: Jan Kara --- fs/udf/super.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index 7712fa4b5a3d..335f9493875c 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1593,6 +1593,21 @@ static void udf_load_logicalvolint(struct super_block *sb, struct kernel_extent_ sbi->s_lvid_bh = NULL; } +static struct udf_vds_record *get_volume_descriptor_record( + struct udf_vds_record *vds, uint16_t ident) +{ + switch (ident) { + case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */ + return &vds[VDS_POS_PRIMARY_VOL_DESC]; + case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */ + return &vds[VDS_POS_IMP_USE_VOL_DESC]; + case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ + return &vds[VDS_POS_LOGICAL_VOL_DESC]; + case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ + return &vds[VDS_POS_UNALLOC_SPACE_DESC]; + } + return NULL +} /* * Process a main/reserve volume descriptor sequence. @@ -1635,13 +1650,6 @@ static noinline int udf_process_sequence( gd = (struct generic_desc *)bh->b_data; vdsn = le32_to_cpu(gd->volDescSeqNum); switch (ident) { - case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */ - curr = &vds[VDS_POS_PRIMARY_VOL_DESC]; - if (vdsn >= curr->volDescSeqNum) { - curr->volDescSeqNum = vdsn; - curr->block = block; - } - break; case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */ if (++indirections > UDF_MAX_TD_NESTING) { udf_err(sb, "too many Volume Descriptor " @@ -1660,8 +1668,11 @@ static noinline int udf_process_sequence( /* For loop is going to increment 'block' again */ block--; break; + case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */ case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */ - curr = &vds[VDS_POS_IMP_USE_VOL_DESC]; + case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ + case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ + curr = get_volume_descriptor_record(vds, ident); if (vdsn >= curr->volDescSeqNum) { curr->volDescSeqNum = vdsn; curr->block = block; @@ -1672,20 +1683,6 @@ static noinline int udf_process_sequence( if (!curr->block) curr->block = block; break; - case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ - curr = &vds[VDS_POS_LOGICAL_VOL_DESC]; - if (vdsn >= curr->volDescSeqNum) { - curr->volDescSeqNum = vdsn; - curr->block = block; - } - break; - case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ - curr = &vds[VDS_POS_UNALLOC_SPACE_DESC]; - if (vdsn >= curr->volDescSeqNum) { - curr->volDescSeqNum = vdsn; - curr->block = block; - } - break; case TAG_IDENT_TD: /* ISO 13346 3/10.9 */ vds[VDS_POS_TERMINATING_DESC].block = block; done = true;