diff options
author | Jan Kara <jack@suse.cz> | 2010-10-20 18:28:46 +0200 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2011-01-06 17:03:55 +0100 |
commit | d664b6af609ecf5e7dcedf92f0bf188e3a29b3e0 (patch) | |
tree | 865eb1db44abdceefea52e46117af61051b610e8 /fs/udf/super.c | |
parent | 49521de119d326d04fb3736ab827e12e1de966d0 (diff) | |
download | op-kernel-dev-d664b6af609ecf5e7dcedf92f0bf188e3a29b3e0.zip op-kernel-dev-d664b6af609ecf5e7dcedf92f0bf188e3a29b3e0.tar.gz |
udf: Move handling of uniqueID into a helper function and protect it by a s_alloc_mutex
uniqueID handling has been duplicated in three places. Move it into a common
helper. Since we modify an LVID buffer with uniqueID update, we take
sbi->s_alloc_mutex to protect agaist other modifications of the structure.
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/super.c')
-rw-r--r-- | fs/udf/super.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c index f99ff5d..948e1ac 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1823,6 +1823,33 @@ static void udf_close_lvid(struct super_block *sb) sbi->s_lvid_dirty = 0; } +u64 lvid_get_unique_id(struct super_block *sb) +{ + struct buffer_head *bh; + struct udf_sb_info *sbi = UDF_SB(sb); + struct logicalVolIntegrityDesc *lvid; + struct logicalVolHeaderDesc *lvhd; + u64 uniqueID; + u64 ret; + + bh = sbi->s_lvid_bh; + if (!bh) + return 0; + + lvid = (struct logicalVolIntegrityDesc *)bh->b_data; + lvhd = (struct logicalVolHeaderDesc *)lvid->logicalVolContentsUse; + + mutex_lock(&sbi->s_alloc_mutex); + ret = uniqueID = le64_to_cpu(lvhd->uniqueID); + if (!(++uniqueID & 0xFFFFFFFF)) + uniqueID += 16; + lvhd->uniqueID = cpu_to_le64(uniqueID); + mutex_unlock(&sbi->s_alloc_mutex); + mark_buffer_dirty(bh); + + return ret; +} + static void udf_sb_free_bitmap(struct udf_bitmap *bitmap) { int i; |