diff options
| author | Jan Kara <jack@suse.cz> | 2010-10-20 12:28:46 -0400 |
|---|---|---|
| committer | Jan Kara <jack@suse.cz> | 2011-01-06 11:03:55 -0500 |
| commit | d664b6af609ecf5e7dcedf92f0bf188e3a29b3e0 (patch) | |
| tree | 865eb1db44abdceefea52e46117af61051b610e8 /fs/udf/super.c | |
| parent | 49521de119d326d04fb3736ab827e12e1de966d0 (diff) | |
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 f99ff5dbd741..948e1aca0f34 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
| @@ -1823,6 +1823,33 @@ static void udf_close_lvid(struct super_block *sb) | |||
| 1823 | sbi->s_lvid_dirty = 0; | 1823 | sbi->s_lvid_dirty = 0; |
| 1824 | } | 1824 | } |
| 1825 | 1825 | ||
| 1826 | u64 lvid_get_unique_id(struct super_block *sb) | ||
| 1827 | { | ||
| 1828 | struct buffer_head *bh; | ||
| 1829 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
| 1830 | struct logicalVolIntegrityDesc *lvid; | ||
| 1831 | struct logicalVolHeaderDesc *lvhd; | ||
| 1832 | u64 uniqueID; | ||
| 1833 | u64 ret; | ||
| 1834 | |||
| 1835 | bh = sbi->s_lvid_bh; | ||
| 1836 | if (!bh) | ||
| 1837 | return 0; | ||
| 1838 | |||
| 1839 | lvid = (struct logicalVolIntegrityDesc *)bh->b_data; | ||
| 1840 | lvhd = (struct logicalVolHeaderDesc *)lvid->logicalVolContentsUse; | ||
| 1841 | |||
| 1842 | mutex_lock(&sbi->s_alloc_mutex); | ||
| 1843 | ret = uniqueID = le64_to_cpu(lvhd->uniqueID); | ||
| 1844 | if (!(++uniqueID & 0xFFFFFFFF)) | ||
| 1845 | uniqueID += 16; | ||
| 1846 | lvhd->uniqueID = cpu_to_le64(uniqueID); | ||
| 1847 | mutex_unlock(&sbi->s_alloc_mutex); | ||
| 1848 | mark_buffer_dirty(bh); | ||
| 1849 | |||
| 1850 | return ret; | ||
| 1851 | } | ||
| 1852 | |||
| 1826 | static void udf_sb_free_bitmap(struct udf_bitmap *bitmap) | 1853 | static void udf_sb_free_bitmap(struct udf_bitmap *bitmap) |
| 1827 | { | 1854 | { |
| 1828 | int i; | 1855 | int i; |
