Skip to contentSkip to conversation

udf : skip mirror metadata FE since metadata FE is ok.

PATCH Superseded Namjae Jeon 2 participants 4 messages Oct 19, 2011 – Oct 23, 2011 UDF filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udf : skip mirror metadata FE since metadata FE is ok.

By Jan Kara's suggestion, This patch skip mirror metadata FE since metadata FE is ok. And try to read it only the first time udf_get_pblock_meta25() fails to map the block from metadata FE.

---
 fs/udf/partition.c |   20 ++++++++++++++++++++
 fs/udf/super.c     |   33 ++++++++++++++++-----------------
 2 files changed, 36 insertions(+), 17 deletions(-)
fs/udf/partition.c +20 -0
index f3e472c..8bfc25b 100644
@@ -311,6 +311,7 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
 	struct udf_meta_data *mdata;
 	uint32_t retblk;
 	struct inode *inode;
+	struct kernel_lb_addr addr;
 
 	udf_debug("READING from METADATA\n");
 
@@ -323,6 +324,25 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
 	retblk = udf_try_read_meta(inode, block, partition, offset);
 	if (retblk == 0xFFFFFFFF) {
 		udf_warn(sb, "error reading from METADATA, trying to read from MIRROR\n");
+		if (mdata->s_mirror_fe == NULL) {
+			/* mirror file entry */
+			addr.logicalBlockNum = mdata->s_mirror_file_loc;
+			addr.partitionReferenceNum = map->s_partition_num;
+			udf_debug("Mirror metadata file location: block = %d part = %d\n",
+				addr.logicalBlockNum,
+				addr.partitionReferenceNum);
+			mdata->s_mirror_fe = udf_iget(sb, &addr);
+
+			if (mdata->s_mirror_fe == NULL)
+				udf_err(sb, "mirror inode efe not found");
+			else if (UDF_I(mdata->s_mirror_fe)->i_alloc_type !=
+					ICBTAG_FLAG_AD_SHORT) {
+				udf_warn(sb, "mirror inode efe does not have short allocation descriptors!\n");
+				iput(mdata->s_mirror_fe);
+				mdata->s_mirror_fe = NULL;
+			}
+		}
+
 		inode = mdata->s_mirror_fe;
 		if (!inode)
 			return 0xFFFFFFFF;
fs/udf/super.c +16 -17
index e58123a..659d088 100644
@@ -857,29 +857,28 @@ static int udf_load_metadata_files(struct super_block *sb, int partition)
 		mdata->s_metadata_fe = NULL;
 	}
 
-	/* mirror file entry */
-	addr.logicalBlockNum = mdata->s_mirror_file_loc;
-	addr.partitionReferenceNum = map->s_partition_num;
+	if (fe_error) {
+		/* mirror file entry */
+		addr.logicalBlockNum = mdata->s_mirror_file_loc;
+		addr.partitionReferenceNum = map->s_partition_num;
 
-	udf_debug("Mirror metadata file location: block = %d part = %d\n",
-		  addr.logicalBlockNum, addr.partitionReferenceNum);
+		udf_debug("Mirror metadata file location: block = %d part = %d\n",
+			  addr.logicalBlockNum, addr.partitionReferenceNum);
 
-	mdata->s_mirror_fe = udf_iget(sb, &addr);
+		mdata->s_mirror_fe = udf_iget(sb, &addr);
 
-	if (mdata->s_mirror_fe == NULL) {
-		if (fe_error) {
+		if (mdata->s_mirror_fe == NULL) {
 			udf_err(sb, "mirror inode efe not found and metadata inode is missing too, exiting...\n");
 			goto error_exit;
-		} else
-			udf_warn(sb, "mirror inode efe not found, but metadata inode is OK\n");
-	} else if (UDF_I(mdata->s_mirror_fe)->i_alloc_type !=
-		 ICBTAG_FLAG_AD_SHORT) {
-		udf_warn(sb, "mirror inode efe does not have short allocation descriptors!\n");
-		iput(mdata->s_mirror_fe);
-		mdata->s_mirror_fe = NULL;
-		if (fe_error)
+		} else if (UDF_I(mdata->s_mirror_fe)->i_alloc_type !=
+				ICBTAG_FLAG_AD_SHORT) {
+			udf_warn(sb, "mirror inode efe does not have short allocation descriptors!\n");
+			iput(mdata->s_mirror_fe);
+			mdata->s_mirror_fe = NULL;
 			goto error_exit;
-	}
+		}
+	} else
+		mdata->s_mirror_fe = NULL;
 
 	/*
 	 * bitmap file entry
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 24 lines · Namjae Jeon

By Jan Kara's suggestion, This patch skip mirror metadata FE since metadata FE is ok. And try to read it only the first time udf_get_pblock_meta25() fails to map the block from metadata FE.

---
 fs/udf/partition.c |   20 ++++++++++++++++++++
 fs/udf/super.c     |   33 ++++++++++++++++-----------------
 2 files changed, 36 insertions(+), 17 deletions(-)
fs/udf/partition.c +1 -0
index f3e472c..8bfc25b 100644
@@ -311,6 +311,7 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
 	struct udf_meta_data *mdata;
 	uint32_t retblk;
 	struct inode *inode;
+	struct kernel_lb_addr addr;
 
 	udf_debug("READING from METADATA\n");
 

fs/udf/partition.c uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block, · line 327

Quoted 4 lines
fs/udf/partition.c +1 -0
@@ -323,6 +324,25 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
 	retblk = udf_try_read_meta(inode, block, partition, offset);
 	if (retblk == 0xFFFFFFFF) {
 		udf_warn(sb, "error reading from METADATA, trying to read from MIRROR\n");
+		if (mdata->s_mirror_fe == NULL) {

This won't be good because if s_mirror_fe cannot be loaded as well, you'd
just try loading it on every block mapping which failed from the primary metadata map. So you should have a flag somewhere whether in mdata, whether you tried loading mirror_fe or not and use that.

Quoted 6 lines
fs/udf/partition.c +6 -0
+			/* mirror file entry */
+			addr.logicalBlockNum = mdata->s_mirror_file_loc;
+			addr.partitionReferenceNum = map->s_partition_num;
+			udf_debug("Mirror metadata file location: block = %d part = %d\n",
+				addr.logicalBlockNum,
+				addr.partitionReferenceNum);

fs/udf/partition.c uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block, · line 343

Quoted 10 lines
fs/udf/partition.c +10 -0
+			mdata->s_mirror_fe = udf_iget(sb, &addr);
+
+			if (mdata->s_mirror_fe == NULL)
+				udf_err(sb, "mirror inode efe not found");
+			else if (UDF_I(mdata->s_mirror_fe)->i_alloc_type !=
+					ICBTAG_FLAG_AD_SHORT) {
+				udf_warn(sb, "mirror inode efe does not have short allocation descriptors!\n");
+				iput(mdata->s_mirror_fe);
+				mdata->s_mirror_fe = NULL;
+			}

Also please create a helper function for loading metadata/mirror metadat
FE so that we don't have loading duplicated in three places... Thanks.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#2 lore raw

2011/10/21 Jan Kara <[email protected]>:

Quoted 50 lines · Namjae Jeon
Quoted 24 lines

By Jan Kara's suggestion, This patch skip mirror metadata FE since metadata FE is ok. And try to read it only the first time udf_get_pblock_meta25() fails to map the block from metadata FE.

---
 fs/udf/partition.c |   20 ++++++++++++++++++++ fs/udf/super.c     |   33 ++++++++++++++++-----------------

 2 files changed, 36 insertions(+), 17 deletions(-)
fs/udf/partition.c +1 -0
index f3e472c..8bfc25b 100644
@@ -311,6 +311,7 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
       struct udf_meta_data *mdata;
       uint32_t retblk;
       struct inode *inode;
+     struct kernel_lb_addr addr;
 
       udf_debug("READING from METADATA\n");
 

fs/udf/partition.c uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block, · line 327

Quoted 4 lines
fs/udf/partition.c +1 -0
@@ -323,6 +324,25 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
       retblk = udf_try_read_meta(inode, block, partition, offset);
       if (retblk == 0xFFFFFFFF) {
               udf_warn(sb, "error reading from METADATA, trying to read from MIRROR\n");
+             if (mdata->s_mirror_fe == NULL) {

 This won't be good because if s_mirror_fe cannot be loaded as well, you'd just try loading it on every block mapping which failed from the primary metadata map. So you should have a flag somewhere whether in mdata, whether you tried loading mirror_fe or not and use that.

Quoted 6 lines
fs/udf/partition.c +6 -0
+                     /* mirror file entry */
+                     addr.logicalBlockNum = mdata->s_mirror_file_loc;
+                     addr.partitionReferenceNum = map->s_partition_num;
+                     udf_debug("Mirror metadata file location: block = %d part = %d\n",
+                             addr.logicalBlockNum,
+                             addr.partitionReferenceNum);

fs/udf/partition.c uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block, · line 343

Quoted 10 lines
fs/udf/partition.c +10 -0
+                     mdata->s_mirror_fe = udf_iget(sb, &addr);
+
+                     if (mdata->s_mirror_fe == NULL)
+                             udf_err(sb, "mirror inode efe not found");
+                     else if (UDF_I(mdata->s_mirror_fe)->i_alloc_type !=
+                                     ICBTAG_FLAG_AD_SHORT) {
+                             udf_warn(sb, "mirror inode efe does not have short allocation descriptors!\n");
+                             iput(mdata->s_mirror_fe);
+                             mdata->s_mirror_fe = NULL;
+                     }
Quoted 2 lines

 Also please create a helper function for loading metadata/mirror metadat FE so that we don't have loading duplicated in three places... Thanks.

Hi Jan.
Thanks for your review.
I will do it.

Quoted 6 lines

                                                               Honza --
Jan Kara <[email protected]>
SUSE Labs, CR

#3 lore raw
In reply to Jan Kara

2011/10/21 Jan Kara <[email protected]>:

Quoted 50 lines · Namjae Jeon
Quoted 24 lines

By Jan Kara's suggestion, This patch skip mirror metadata FE since metadata FE is ok. And try to read it only the first time udf_get_pblock_meta25() fails to map the block from metadata FE.

---
 fs/udf/partition.c |   20 ++++++++++++++++++++ fs/udf/super.c     |   33 ++++++++++++++++-----------------

 2 files changed, 36 insertions(+), 17 deletions(-)
fs/udf/partition.c +1 -0
index f3e472c..8bfc25b 100644
@@ -311,6 +311,7 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
       struct udf_meta_data *mdata;
       uint32_t retblk;
       struct inode *inode;
+     struct kernel_lb_addr addr;
 
       udf_debug("READING from METADATA\n");
 

fs/udf/partition.c uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block, · line 327

Quoted 4 lines
fs/udf/partition.c +1 -0
@@ -323,6 +324,25 @@ uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block,
       retblk = udf_try_read_meta(inode, block, partition, offset);
       if (retblk == 0xFFFFFFFF) {
               udf_warn(sb, "error reading from METADATA, trying to read from MIRROR\n");
+             if (mdata->s_mirror_fe == NULL) {

 This won't be good because if s_mirror_fe cannot be loaded as well, you'd just try loading it on every block mapping which failed from the primary metadata map. So you should have a flag somewhere whether in mdata, whether you tried loading mirror_fe or not and use that.

Quoted 6 lines
fs/udf/partition.c +6 -0
+                     /* mirror file entry */
+                     addr.logicalBlockNum = mdata->s_mirror_file_loc;
+                     addr.partitionReferenceNum = map->s_partition_num;
+                     udf_debug("Mirror metadata file location: block = %d part = %d\n",
+                             addr.logicalBlockNum,
+                             addr.partitionReferenceNum);

fs/udf/partition.c uint32_t udf_get_pblock_meta25(struct super_block *sb, uint32_t block, · line 343

Quoted 10 lines
fs/udf/partition.c +10 -0
+                     mdata->s_mirror_fe = udf_iget(sb, &addr);
+
+                     if (mdata->s_mirror_fe == NULL)
+                             udf_err(sb, "mirror inode efe not found");
+                     else if (UDF_I(mdata->s_mirror_fe)->i_alloc_type !=
+                                     ICBTAG_FLAG_AD_SHORT) {
+                             udf_warn(sb, "mirror inode efe does not have short allocation descriptors!\n");
+                             iput(mdata->s_mirror_fe);
+                             mdata->s_mirror_fe = NULL;
+                     }
Quoted 2 lines

 Also please create a helper function for loading metadata/mirror metadat FE so that we don't have loading duplicated in three places... Thanks.

Hi Jan.
Thanks for your review.
I will do it.

Quoted 6 lines

                                                               Honza --
Jan Kara <[email protected]>
SUSE Labs, CR