aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2011-04-19 22:31:50 -0400
committerLi Zefan <lizf@cn.fujitsu.com>2011-04-25 04:46:09 -0400
commit33345d01522f8152f99dc84a3e7a1a45707f387f (patch)
tree6a978702dc4421768e63501fa15bc8fedd5bff32 /fs/btrfs/ioctl.c
parent0414efae7989a2183fb2cc000ab285c4c2836a00 (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/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index e1835f8eec93..01dccb4a70bb 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -416,7 +416,7 @@ static noinline int create_subvol(struct btrfs_root *root,
416 BUG_ON(ret); 416 BUG_ON(ret);
417 417
418 ret = btrfs_insert_dir_item(trans, root, 418 ret = btrfs_insert_dir_item(trans, root,
419 name, namelen, dir->i_ino, &key, 419 name, namelen, btrfs_ino(dir), &key,
420 BTRFS_FT_DIR, index); 420 BTRFS_FT_DIR, index);
421 if (ret) 421 if (ret)
422 goto fail; 422 goto fail;
@@ -427,7 +427,7 @@ static noinline int create_subvol(struct btrfs_root *root,
427 427
428 ret = btrfs_add_root_ref(trans, root->fs_info->tree_root, 428 ret = btrfs_add_root_ref(trans, root->fs_info->tree_root,
429 objectid, root->root_key.objectid, 429 objectid, root->root_key.objectid,
430 dir->i_ino, index, name, namelen); 430 btrfs_ino(dir), index, name, namelen);
431 431
432 BUG_ON(ret); 432 BUG_ON(ret);
433 433
@@ -1123,7 +1123,7 @@ static noinline int btrfs_ioctl_subvol_getflags(struct file *file,
1123 int ret = 0; 1123 int ret = 0;
1124 u64 flags = 0; 1124 u64 flags = 0;
1125 1125
1126 if (inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) 1126 if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID)
1127 return -EINVAL; 1127 return -EINVAL;
1128 1128
1129 down_read(&root->fs_info->subvol_sem); 1129 down_read(&root->fs_info->subvol_sem);
@@ -1150,7 +1150,7 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
1150 if (root->fs_info->sb->s_flags & MS_RDONLY) 1150 if (root->fs_info->sb->s_flags & MS_RDONLY)
1151 return -EROFS; 1151 return -EROFS;
1152 1152
1153 if (inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) 1153 if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID)
1154 return -EINVAL; 1154 return -EINVAL;
1155 1155
1156 if (copy_from_user(&flags, arg, sizeof(flags))) 1156 if (copy_from_user(&flags, arg, sizeof(flags)))
@@ -1633,7 +1633,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
1633 goto out_dput; 1633 goto out_dput;
1634 } 1634 }
1635 1635
1636 if (inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) { 1636 if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID) {
1637 err = -EINVAL; 1637 err = -EINVAL;
1638 goto out_dput; 1638 goto out_dput;
1639 } 1639 }
@@ -1919,7 +1919,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1919 } 1919 }
1920 1920
1921 /* clone data */ 1921 /* clone data */
1922 key.objectid = src->i_ino; 1922 key.objectid = btrfs_ino(src);
1923 key.type = BTRFS_EXTENT_DATA_KEY; 1923 key.type = BTRFS_EXTENT_DATA_KEY;
1924 key.offset = 0; 1924 key.offset = 0;
1925 1925
@@ -1946,7 +1946,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1946 1946
1947 btrfs_item_key_to_cpu(leaf, &key, slot); 1947 btrfs_item_key_to_cpu(leaf, &key, slot);
1948 if (btrfs_key_type(&key) > BTRFS_EXTENT_DATA_KEY || 1948 if (btrfs_key_type(&key) > BTRFS_EXTENT_DATA_KEY ||
1949 key.objectid != src->i_ino) 1949 key.objectid != btrfs_ino(src))
1950 break; 1950 break;
1951 1951
1952 if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY) { 1952 if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY) {
@@ -1989,7 +1989,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1989 goto next; 1989 goto next;
1990 1990
1991 memcpy(&new_key, &key, sizeof(new_key)); 1991 memcpy(&new_key, &key, sizeof(new_key));
1992 new_key.objectid = inode->i_ino; 1992 new_key.objectid = btrfs_ino(inode);
1993 if (off <= key.offset) 1993 if (off <= key.offset)
1994 new_key.offset = key.offset + destoff - off; 1994 new_key.offset = key.offset + destoff - off;
1995 else 1995 else
@@ -2043,7 +2043,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
2043 ret = btrfs_inc_extent_ref(trans, root, 2043 ret = btrfs_inc_extent_ref(trans, root,
2044 disko, diskl, 0, 2044 disko, diskl, 0,
2045 root->root_key.objectid, 2045 root->root_key.objectid,
2046 inode->i_ino, 2046 btrfs_ino(inode),
2047 new_key.offset - datao); 2047 new_key.offset - datao);
2048 BUG_ON(ret); 2048 BUG_ON(ret);
2049 } 2049 }