diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2011-04-19 22:31:50 -0400 |
---|---|---|
committer | Li Zefan <lizf@cn.fujitsu.com> | 2011-04-25 04:46:09 -0400 |
commit | 33345d01522f8152f99dc84a3e7a1a45707f387f (patch) | |
tree | 6a978702dc4421768e63501fa15bc8fedd5bff32 /fs/btrfs/relocation.c | |
parent | 0414efae7989a2183fb2cc000ab285c4c2836a00 (diff) |
Btrfs: Always use 64bit inode number
There's a potential problem in 32bit system when we exhaust 32bit inode
numbers and start to allocate big inode numbers, because btrfs uses
inode->i_ino in many places.
So here we always use BTRFS_I(inode)->location.objectid, which is an
u64 variable.
There are 2 exceptions that BTRFS_I(inode)->location.objectid !=
inode->i_ino: the btree inode (0 vs 1) and empty subvol dirs (256 vs 2),
and inode->i_ino will be used in those cases.
Another reason to make this change is I'm going to use a special inode
to save free ino cache, and the inode number must be > (u64)-256.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'fs/btrfs/relocation.c')
-rw-r--r-- | fs/btrfs/relocation.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index e6cb89357256..7b75e0c8ef8d 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
@@ -1410,9 +1410,9 @@ again: | |||
1410 | prev = node; | 1410 | prev = node; |
1411 | entry = rb_entry(node, struct btrfs_inode, rb_node); | 1411 | entry = rb_entry(node, struct btrfs_inode, rb_node); |
1412 | 1412 | ||
1413 | if (objectid < entry->vfs_inode.i_ino) | 1413 | if (objectid < btrfs_ino(&entry->vfs_inode)) |
1414 | node = node->rb_left; | 1414 | node = node->rb_left; |
1415 | else if (objectid > entry->vfs_inode.i_ino) | 1415 | else if (objectid > btrfs_ino(&entry->vfs_inode)) |
1416 | node = node->rb_right; | 1416 | node = node->rb_right; |
1417 | else | 1417 | else |
1418 | break; | 1418 | break; |
@@ -1420,7 +1420,7 @@ again: | |||
1420 | if (!node) { | 1420 | if (!node) { |
1421 | while (prev) { | 1421 | while (prev) { |
1422 | entry = rb_entry(prev, struct btrfs_inode, rb_node); | 1422 | entry = rb_entry(prev, struct btrfs_inode, rb_node); |
1423 | if (objectid <= entry->vfs_inode.i_ino) { | 1423 | if (objectid <= btrfs_ino(&entry->vfs_inode)) { |
1424 | node = prev; | 1424 | node = prev; |
1425 | break; | 1425 | break; |
1426 | } | 1426 | } |
@@ -1435,7 +1435,7 @@ again: | |||
1435 | return inode; | 1435 | return inode; |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | objectid = entry->vfs_inode.i_ino + 1; | 1438 | objectid = btrfs_ino(&entry->vfs_inode) + 1; |
1439 | if (cond_resched_lock(&root->inode_lock)) | 1439 | if (cond_resched_lock(&root->inode_lock)) |
1440 | goto again; | 1440 | goto again; |
1441 | 1441 | ||
@@ -1471,7 +1471,7 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr, | |||
1471 | return -ENOMEM; | 1471 | return -ENOMEM; |
1472 | 1472 | ||
1473 | bytenr -= BTRFS_I(reloc_inode)->index_cnt; | 1473 | bytenr -= BTRFS_I(reloc_inode)->index_cnt; |
1474 | ret = btrfs_lookup_file_extent(NULL, root, path, reloc_inode->i_ino, | 1474 | ret = btrfs_lookup_file_extent(NULL, root, path, btrfs_ino(reloc_inode), |
1475 | bytenr, 0); | 1475 | bytenr, 0); |
1476 | if (ret < 0) | 1476 | if (ret < 0) |
1477 | goto out; | 1477 | goto out; |
@@ -1559,11 +1559,11 @@ int replace_file_extents(struct btrfs_trans_handle *trans, | |||
1559 | if (first) { | 1559 | if (first) { |
1560 | inode = find_next_inode(root, key.objectid); | 1560 | inode = find_next_inode(root, key.objectid); |
1561 | first = 0; | 1561 | first = 0; |
1562 | } else if (inode && inode->i_ino < key.objectid) { | 1562 | } else if (inode && btrfs_ino(inode) < key.objectid) { |
1563 | btrfs_add_delayed_iput(inode); | 1563 | btrfs_add_delayed_iput(inode); |
1564 | inode = find_next_inode(root, key.objectid); | 1564 | inode = find_next_inode(root, key.objectid); |
1565 | } | 1565 | } |
1566 | if (inode && inode->i_ino == key.objectid) { | 1566 | if (inode && btrfs_ino(inode) == key.objectid) { |
1567 | end = key.offset + | 1567 | end = key.offset + |
1568 | btrfs_file_extent_num_bytes(leaf, fi); | 1568 | btrfs_file_extent_num_bytes(leaf, fi); |
1569 | WARN_ON(!IS_ALIGNED(key.offset, | 1569 | WARN_ON(!IS_ALIGNED(key.offset, |
@@ -1894,6 +1894,7 @@ static int invalidate_extent_cache(struct btrfs_root *root, | |||
1894 | struct inode *inode = NULL; | 1894 | struct inode *inode = NULL; |
1895 | u64 objectid; | 1895 | u64 objectid; |
1896 | u64 start, end; | 1896 | u64 start, end; |
1897 | u64 ino; | ||
1897 | 1898 | ||
1898 | objectid = min_key->objectid; | 1899 | objectid = min_key->objectid; |
1899 | while (1) { | 1900 | while (1) { |
@@ -1906,17 +1907,18 @@ static int invalidate_extent_cache(struct btrfs_root *root, | |||
1906 | inode = find_next_inode(root, objectid); | 1907 | inode = find_next_inode(root, objectid); |
1907 | if (!inode) | 1908 | if (!inode) |
1908 | break; | 1909 | break; |
1910 | ino = btrfs_ino(inode); | ||
1909 | 1911 | ||
1910 | if (inode->i_ino > max_key->objectid) { | 1912 | if (ino > max_key->objectid) { |
1911 | iput(inode); | 1913 | iput(inode); |
1912 | break; | 1914 | break; |
1913 | } | 1915 | } |
1914 | 1916 | ||
1915 | objectid = inode->i_ino + 1; | 1917 | objectid = ino + 1; |
1916 | if (!S_ISREG(inode->i_mode)) | 1918 | if (!S_ISREG(inode->i_mode)) |
1917 | continue; | 1919 | continue; |
1918 | 1920 | ||
1919 | if (unlikely(min_key->objectid == inode->i_ino)) { | 1921 | if (unlikely(min_key->objectid == ino)) { |
1920 | if (min_key->type > BTRFS_EXTENT_DATA_KEY) | 1922 | if (min_key->type > BTRFS_EXTENT_DATA_KEY) |
1921 | continue; | 1923 | continue; |
1922 | if (min_key->type < BTRFS_EXTENT_DATA_KEY) | 1924 | if (min_key->type < BTRFS_EXTENT_DATA_KEY) |
@@ -1929,7 +1931,7 @@ static int invalidate_extent_cache(struct btrfs_root *root, | |||
1929 | start = 0; | 1931 | start = 0; |
1930 | } | 1932 | } |
1931 | 1933 | ||
1932 | if (unlikely(max_key->objectid == inode->i_ino)) { | 1934 | if (unlikely(max_key->objectid == ino)) { |
1933 | if (max_key->type < BTRFS_EXTENT_DATA_KEY) | 1935 | if (max_key->type < BTRFS_EXTENT_DATA_KEY) |
1934 | continue; | 1936 | continue; |
1935 | if (max_key->type > BTRFS_EXTENT_DATA_KEY) { | 1937 | if (max_key->type > BTRFS_EXTENT_DATA_KEY) { |