Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756089Ab0KPRlS (ORCPT ); Tue, 16 Nov 2010 12:41:18 -0500 Received: from mail-ew0-f46.google.com ([209.85.215.46]:33695 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755897Ab0KPRlP (ORCPT ); Tue, 16 Nov 2010 12:41:15 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=WHVgAciLJp15aBCfcFqVVTBrCQQc0GCv0OSH4avVRus35Ebg8UKn78w/IPLJxx3Fsg 4gkelecW9ROTDIG+grUg09lHtYWa1Me0Mnf1leIgKFxwLe8s6Lxgov7S1TYOh3p1hWdk xKOk2exgrbh2v78OQx02bZtjn0eHHMaMBtOkk= From: Alessio Igor Bogani To: Jan Kara , Arnd Bergmann Cc: Christoph Hellwig , Tim Bird , LKML , linux-fsdevel@vger.kernel.org, Alessio Igor Bogani Subject: [PATCH 2/3] udf: Use of s_alloc_mutex to serialize udf_relocate_blocks() execution Date: Tue, 16 Nov 2010 18:40:48 +0100 Message-Id: <1289929249-4863-2-git-send-email-abogani@texware.it> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1289929249-4863-1-git-send-email-abogani@texware.it> References: <1289929249-4863-1-git-send-email-abogani@texware.it> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2695 Lines: 98 This work was supported by a hardware donation from the CE Linux Forum. Signed-off-by: Alessio Igor Bogani --- fs/udf/partition.c | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-) diff --git a/fs/udf/partition.c b/fs/udf/partition.c index 745eb20..a71090e 100644 --- a/fs/udf/partition.c +++ b/fs/udf/partition.c @@ -25,6 +25,7 @@ #include #include #include +#include uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, uint16_t partition, uint32_t offset) @@ -159,7 +160,9 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) struct udf_sb_info *sbi = UDF_SB(sb); u16 reallocationTableLen; struct buffer_head *bh; + int ret = 0; + mutex_lock(&sbi->s_alloc_mutex); for (i = 0; i < sbi->s_partitions; i++) { struct udf_part_map *map = &sbi->s_partmaps[i]; if (old_block > map->s_partition_root && @@ -175,8 +178,10 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) break; } - if (!st) - return 1; + if (!st) { + ret = 1; + goto out; + } reallocationTableLen = le16_to_cpu(st->reallocationTableLen); @@ -207,14 +212,16 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) ((old_block - map->s_partition_root) & (sdata->s_packet_len - 1)); - return 0; + ret = 0; + goto out; } else if (origLoc == packet) { *new_block = le32_to_cpu( entry->mappedLocation) + ((old_block - map->s_partition_root) & (sdata->s_packet_len - 1)); - return 0; + ret = 0; + goto out; } else if (origLoc > packet) break; } @@ -251,20 +258,24 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) st->mapEntry[k].mappedLocation) + ((old_block - map->s_partition_root) & (sdata->s_packet_len - 1)); - return 0; + ret = 0; + goto out; } - return 1; + ret = 1; + goto out; } /* if old_block */ } if (i == sbi->s_partitions) { /* outside of partitions */ /* for now, fail =) */ - return 1; + ret = 1; } - return 0; +out: + mutex_unlock(&sbi->s_alloc_mutex); + return ret; } static uint32_t udf_try_read_meta(struct inode *inode, uint32_t block, -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/