diff options
author | Martin J. Bligh <mbligh@mbligh.org> | 2007-10-17 02:30:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 11:43:02 -0400 |
commit | a686cd898bd999fd026a51e90fb0a3410d258ddb (patch) | |
tree | 3f0a91a70fe1a3addf9e99f3babed9e9baba4b99 /fs/ext2/ioctl.c | |
parent | 369f2389e7d03022abdd25e298bffb9613cd0e54 (diff) |
ext2 reservations
Val's cross-port of the ext3 reservations code into ext2.
[mbligh@mbligh.org: Small type error for printk
[akpm@linux-foundation.org: fix types, sync with ext3]
[mbligh@mbligh.org: Bring ext2 reservations code in line with latest ext3]
[akpm@linux-foundation.org: kill noisy printk]
[akpm@linux-foundation.org: remember to dirty the gdp's block]
[akpm@linux-foundation.org: cross-port the missed 5dea5176e5c32ef9f0d1a41d28427b3bf6881b3a]
[akpm@linux-foundation.org: cross-port e6022603b9aa7d61d20b392e69edcdbbc1789969]
[akpm@linux-foundation.org: Port the omitted 08fb306fe63d98eb86e3b16f4cc21816fa47f18e]
[akpm@linux-foundation.org: Backport the missed 20acaa18d0c002fec180956f87adeb3f11f635a6]
[akpm@linux-foundation.org: fixes]
[cmm@us.ibm.com: fix reservation extension]
[bunk@stusta.de: make ext2_get_blocks() static]
[hugh@veritas.com: fix hang]
[hugh@veritas.com: ext2_new_blocks should reset the reservation window size]
[hugh@veritas.com: ext2 balloc: fix off-by-one against rsv_end]
[hugh@veritas.com: grp_goal 0 is a genuine goal (unlike -1), so ext2_try_to_allocate_with_rsv should treat it as such]
[hugh@veritas.com: rbtree usage cleanup]
[pbadari@us.ibm.com: Fix for ext2 reservation]
[bunk@kernel.org: remove fs/ext2/balloc.c:reserve_blocks()]
[hugh@veritas.com: ext2 balloc: use io_error label]
Cc: "Martin J. Bligh" <mbligh@mbligh.org>
Cc: Valerie Henson <val_henson@linux.intel.com>
Cc: Mingming Cao <cmm@us.ibm.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext2/ioctl.c')
-rw-r--r-- | fs/ext2/ioctl.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c index 3bcd25422ee4..c2324d5fe4ac 100644 --- a/fs/ext2/ioctl.c +++ b/fs/ext2/ioctl.c | |||
@@ -22,6 +22,7 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, | |||
22 | { | 22 | { |
23 | struct ext2_inode_info *ei = EXT2_I(inode); | 23 | struct ext2_inode_info *ei = EXT2_I(inode); |
24 | unsigned int flags; | 24 | unsigned int flags; |
25 | unsigned short rsv_window_size; | ||
25 | 26 | ||
26 | ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg); | 27 | ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg); |
27 | 28 | ||
@@ -83,6 +84,50 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, | |||
83 | inode->i_ctime = CURRENT_TIME_SEC; | 84 | inode->i_ctime = CURRENT_TIME_SEC; |
84 | mark_inode_dirty(inode); | 85 | mark_inode_dirty(inode); |
85 | return 0; | 86 | return 0; |
87 | case EXT2_IOC_GETRSVSZ: | ||
88 | if (test_opt(inode->i_sb, RESERVATION) | ||
89 | && S_ISREG(inode->i_mode) | ||
90 | && ei->i_block_alloc_info) { | ||
91 | rsv_window_size = ei->i_block_alloc_info->rsv_window_node.rsv_goal_size; | ||
92 | return put_user(rsv_window_size, (int __user *)arg); | ||
93 | } | ||
94 | return -ENOTTY; | ||
95 | case EXT2_IOC_SETRSVSZ: { | ||
96 | |||
97 | if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode)) | ||
98 | return -ENOTTY; | ||
99 | |||
100 | if (IS_RDONLY(inode)) | ||
101 | return -EROFS; | ||
102 | |||
103 | if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) | ||
104 | return -EACCES; | ||
105 | |||
106 | if (get_user(rsv_window_size, (int __user *)arg)) | ||
107 | return -EFAULT; | ||
108 | |||
109 | if (rsv_window_size > EXT2_MAX_RESERVE_BLOCKS) | ||
110 | rsv_window_size = EXT2_MAX_RESERVE_BLOCKS; | ||
111 | |||
112 | /* | ||
113 | * need to allocate reservation structure for this inode | ||
114 | * before set the window size | ||
115 | */ | ||
116 | /* | ||
117 | * XXX What lock should protect the rsv_goal_size? | ||
118 | * Accessed in ext2_get_block only. ext3 uses i_truncate. | ||
119 | */ | ||
120 | mutex_lock(&ei->truncate_mutex); | ||
121 | if (!ei->i_block_alloc_info) | ||
122 | ext2_init_block_alloc_info(inode); | ||
123 | |||
124 | if (ei->i_block_alloc_info){ | ||
125 | struct ext2_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node; | ||
126 | rsv->rsv_goal_size = rsv_window_size; | ||
127 | } | ||
128 | mutex_unlock(&ei->truncate_mutex); | ||
129 | return 0; | ||
130 | } | ||
86 | default: | 131 | default: |
87 | return -ENOTTY; | 132 | return -ENOTTY; |
88 | } | 133 | } |