All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: <linux-fsdevel@vger.kernel.org>
Cc: "Pali Rohár" <pali.rohar@gmail.com>, "Jan Kara" <jack@suse.cz>
Subject: [PATCH 5/6] udf: Unify common handling of descriptors
Date: Wed, 14 Feb 2018 11:28:49 +0100	[thread overview]
Message-ID: <20180214102850.28755-6-jack@suse.cz> (raw)
In-Reply-To: <20180214102850.28755-1-jack@suse.cz>

When scanning Volume Descriptor Sequence, several descriptors have
exactly the same handling. Unify it.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 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;
-- 
2.13.6

  parent reply	other threads:[~2018-02-14 10:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 10:28 [PATCH 0/6] udf: Fix processing of Volume Descriptor Sequence Jan Kara
2018-02-14 10:28 ` [PATCH 1/6] udf: Fix off-by-one in volume descriptor sequence length Jan Kara
2018-02-14 10:28 ` [PATCH 2/6] udf: Simplify handling of Volume Descriptor Pointers Jan Kara
2018-02-14 17:26   ` Pali Rohár
2018-02-15  8:43     ` Jan Kara
2018-02-15 22:33       ` Pali Rohár
2018-02-16 10:16         ` Jan Kara
2018-02-14 10:28 ` [PATCH 3/6] udf: Allow volume descriptor sequence to be terminated by unrecorded block Jan Kara
2018-02-14 10:28 ` [PATCH 4/6] udf: Convert descriptor index definitions to enum Jan Kara
2018-02-14 10:28 ` Jan Kara [this message]
2018-02-14 10:28 ` [PATCH 6/6] udf: Fix handling of Partition Descriptors Jan Kara

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=20180214102850.28755-6-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.