[PATCH 06/10] udf: truncate: create function for updating of Allocation Ext Descriptor

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: LKML <linux-kernel@...>
Cc: Jan Kara <jack@...>, Marcin Slusarz <marcin.slusarz@...>
Date: Wednesday, January 30, 2008 - 5:03 pm

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Jan Kara <jack@suse.cz>
---
 fs/udf/truncate.c |   56 +++++++++++++++++++++-------------------------------
 1 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index f64f827..eb98616 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -180,6 +180,24 @@ void udf_discard_prealloc(struct inode *inode)
 	brelse(epos.bh);
 }
 
+static void udf_update_alloc_ext_desc(struct inode *inode,
+				      struct extent_position *epos,
+				      u32 lenalloc)
+{
+	struct super_block *sb = inode->i_sb;
+	struct udf_sb_info *sbi = UDF_SB(sb);
+
+	struct allocExtDesc *aed = (struct allocExtDesc *) (epos->bh->b_data);
+	int len = sizeof(struct allocExtDesc);
+
+	aed->lengthAllocDescs =	cpu_to_le32(lenalloc);
+	if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || sbi->s_udfrev >= 0x0201)
+		len += lenalloc;
+
+	udf_update_tag(epos->bh->b_data, len);
+	mark_buffer_dirty_inode(epos->bh, inode);
+}
+
 void udf_truncate_extents(struct inode *inode)
 {
 	struct extent_position epos;
@@ -187,7 +205,6 @@ void udf_truncate_extents(struct inode *inode)
 	uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc;
 	int8_t etype;
 	struct super_block *sb = inode->i_sb;
-	struct udf_sb_info *sbi = UDF_SB(sb);
 	sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset;
 	loff_t byte_offset;
 	int adsize;
@@ -230,24 +247,9 @@ void udf_truncate_extents(struct inode *inode)
 				} else if (!epos.bh) {
 					iinfo->i_lenAlloc = lenalloc;
 					mark_inode_dirty(inode);
-				} else {
-					struct allocExtDesc *aed =
-						(struct allocExtDesc *)
-						(epos.bh->b_data);
-					int len = sizeof(struct allocExtDesc);
-
-					aed->lengthAllocDescs =
-						cpu_to_le32(lenalloc);
-					if (!UDF_QUERY_FLAG(sb,
-						UDF_FLAG_STRICT) ||
-						sbi->s_udfrev >= 0x0201)
-						len += lenalloc;
-
-					udf_update_tag(epos.bh->b_data,
-							len);
-					mark_buffer_dirty_inode(
-							epos.bh, inode);
-				}
+				} else
+					udf_update_alloc_ext_desc(inode,
+							&epos, lenalloc);
 				brelse(epos.bh);
 				epos.offset = sizeof(struct allocExtDesc);
 				epos.block = eloc;
@@ -273,20 +275,8 @@ void udf_truncate_extents(struct inode *inode)
 		} else if (!epos.bh) {
 			iinfo->i_lenAlloc = lenalloc;
 			mark_inode_dirty(inode);
-		} else {
-			struct allocExtDesc *aed =
-				(struct allocExtDesc *)(epos.bh->b_data);
-			aed->lengthAllocDescs = cpu_to_le32(lenalloc);
-			if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
-				sbi->s_udfrev >= 0x0201)
-				udf_update_tag(epos.bh->b_data,
-					lenalloc +
-					sizeof(struct allocExtDesc));
-			else
-				udf_update_tag(epos.bh->b_data,
-					sizeof(struct allocExtDesc));
-			mark_buffer_dirty_inode(epos.bh, inode);
-		}
+		} else
+			udf_update_alloc_ext_desc(inode, &epos, lenalloc);
 	} else if (inode->i_size) {
 		if (byte_offset) {
 			kernel_long_ad extent;
-- 
1.5.3.7

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/10] udf: cleanups, , (Wed Jan 30, 5:03 pm)
Re: [PATCH 10/10] udf: constify udf_bitmap_lookup array, Marcin Slusarz, (Sat Feb 2, 5:37 pm)
Re: [PATCH 08/10] udf: simplify __udf_read_inode, Jan Kara, (Thu Jan 31, 12:46 pm)
[PATCH 06/10] udf: truncate: create function for updating of..., , (Wed Jan 30, 5:03 pm)
[PATCH 04/10] udf: constify crc, , (Wed Jan 30, 5:03 pm)
Re: [PATCH 04/10] udf: constify crc, Jan Kara, (Thu Jan 31, 8:58 am)
Re: [PATCH 03/10] udf: udf_CS0toNLS cleanup, Jan Kara, (Thu Jan 31, 8:23 am)
[PATCH 02/10] udf: fix udf_build_ustr, , (Wed Jan 30, 5:03 pm)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Jan Kara, (Thu Jan 31, 6:45 am)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Marcin Slusarz, (Thu Jan 31, 3:57 pm)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Jan Kara, (Mon Feb 4, 3:31 pm)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Marcin Slusarz, (Mon Feb 4, 5:27 pm)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Jan Kara, (Tue Feb 5, 11:29 am)
Re: [PATCH 02/10] udf: fix udf_build_ustr, Marcin Slusarz, (Tue Feb 5, 3:17 pm)
Re: [PATCH 01/10] udf: udf_CS0toUTF8 cleanup, Jan Kara, (Thu Jan 31, 5:57 am)