diff options
Diffstat (limited to 'fs')
125 files changed, 1376 insertions, 1212 deletions
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index c295ba786edd..f0c7de78e205 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h | |||
@@ -41,8 +41,8 @@ extern struct file_system_type v9fs_fs_type; | |||
41 | extern const struct address_space_operations v9fs_addr_operations; | 41 | extern const struct address_space_operations v9fs_addr_operations; |
42 | extern const struct file_operations v9fs_file_operations; | 42 | extern const struct file_operations v9fs_file_operations; |
43 | extern const struct file_operations v9fs_dir_operations; | 43 | extern const struct file_operations v9fs_dir_operations; |
44 | extern struct dentry_operations v9fs_dentry_operations; | 44 | extern const struct dentry_operations v9fs_dentry_operations; |
45 | extern struct dentry_operations v9fs_cached_dentry_operations; | 45 | extern const struct dentry_operations v9fs_cached_dentry_operations; |
46 | 46 | ||
47 | struct inode *v9fs_get_inode(struct super_block *sb, int mode); | 47 | struct inode *v9fs_get_inode(struct super_block *sb, int mode); |
48 | ino_t v9fs_qid2ino(struct p9_qid *qid); | 48 | ino_t v9fs_qid2ino(struct p9_qid *qid); |
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c index 06dcc7c4f234..d74325295b1e 100644 --- a/fs/9p/vfs_dentry.c +++ b/fs/9p/vfs_dentry.c | |||
@@ -104,12 +104,12 @@ void v9fs_dentry_release(struct dentry *dentry) | |||
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | struct dentry_operations v9fs_cached_dentry_operations = { | 107 | const struct dentry_operations v9fs_cached_dentry_operations = { |
108 | .d_delete = v9fs_cached_dentry_delete, | 108 | .d_delete = v9fs_cached_dentry_delete, |
109 | .d_release = v9fs_dentry_release, | 109 | .d_release = v9fs_dentry_release, |
110 | }; | 110 | }; |
111 | 111 | ||
112 | struct dentry_operations v9fs_dentry_operations = { | 112 | const struct dentry_operations v9fs_dentry_operations = { |
113 | .d_delete = v9fs_dentry_delete, | 113 | .d_delete = v9fs_dentry_delete, |
114 | .d_release = v9fs_dentry_release, | 114 | .d_release = v9fs_dentry_release, |
115 | }; | 115 | }; |
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 93212e40221a..5f8ab8adb5f5 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
@@ -168,8 +168,9 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags, | |||
168 | p9stat_free(st); | 168 | p9stat_free(st); |
169 | kfree(st); | 169 | kfree(st); |
170 | 170 | ||
171 | P9_DPRINTK(P9_DEBUG_VFS, " return simple set mount\n"); | 171 | P9_DPRINTK(P9_DEBUG_VFS, " simple set mount, return 0\n"); |
172 | return simple_set_mnt(mnt, sb); | 172 | simple_set_mnt(mnt, sb); |
173 | return 0; | ||
173 | 174 | ||
174 | release_sb: | 175 | release_sb: |
175 | if (sb) { | 176 | if (sb) { |
diff --git a/fs/Kconfig b/fs/Kconfig index 93945dd0b1ae..cef8b18ceaa3 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -56,61 +56,7 @@ endif # BLOCK | |||
56 | 56 | ||
57 | source "fs/notify/Kconfig" | 57 | source "fs/notify/Kconfig" |
58 | 58 | ||
59 | config QUOTA | 59 | source "fs/quota/Kconfig" |
60 | bool "Quota support" | ||
61 | help | ||
62 | If you say Y here, you will be able to set per user limits for disk | ||
63 | usage (also called disk quotas). Currently, it works for the | ||
64 | ext2, ext3, and reiserfs file system. ext3 also supports journalled | ||
65 | quotas for which you don't need to run quotacheck(8) after an unclean | ||
66 | shutdown. | ||
67 | For further details, read the Quota mini-HOWTO, available from | ||
68 | <http://www.tldp.org/docs.html#howto>, or the documentation provided | ||
69 | with the quota tools. Probably the quota support is only useful for | ||
70 | multi user systems. If unsure, say N. | ||
71 | |||
72 | config QUOTA_NETLINK_INTERFACE | ||
73 | bool "Report quota messages through netlink interface" | ||
74 | depends on QUOTA && NET | ||
75 | help | ||
76 | If you say Y here, quota warnings (about exceeding softlimit, reaching | ||
77 | hardlimit, etc.) will be reported through netlink interface. If unsure, | ||
78 | say Y. | ||
79 | |||
80 | config PRINT_QUOTA_WARNING | ||
81 | bool "Print quota warnings to console (OBSOLETE)" | ||
82 | depends on QUOTA | ||
83 | default y | ||
84 | help | ||
85 | If you say Y here, quota warnings (about exceeding softlimit, reaching | ||
86 | hardlimit, etc.) will be printed to the process' controlling terminal. | ||
87 | Note that this behavior is currently deprecated and may go away in | ||
88 | future. Please use notification via netlink socket instead. | ||
89 | |||
90 | # Generic support for tree structured quota files. Seleted when needed. | ||
91 | config QUOTA_TREE | ||
92 | tristate | ||
93 | |||
94 | config QFMT_V1 | ||
95 | tristate "Old quota format support" | ||
96 | depends on QUOTA | ||
97 | help | ||
98 | This quota format was (is) used by kernels earlier than 2.4.22. If | ||
99 | you have quota working and you don't want to convert to new quota | ||
100 | format say Y here. | ||
101 | |||
102 | config QFMT_V2 | ||
103 | tristate "Quota format v2 support" | ||
104 | depends on QUOTA | ||
105 | select QUOTA_TREE | ||
106 | help | ||
107 | This quota format allows using quotas with 32-bit UIDs/GIDs. If you | ||
108 | need this functionality say Y here. | ||
109 | |||
110 | config QUOTACTL | ||
111 | bool | ||
112 | depends on XFS_QUOTA || QUOTA | ||
113 | default y | ||
114 | 60 | ||
115 | source "fs/autofs/Kconfig" | 61 | source "fs/autofs/Kconfig" |
116 | source "fs/autofs4/Kconfig" | 62 | source "fs/autofs4/Kconfig" |
diff --git a/fs/Makefile b/fs/Makefile index dc20db348679..6e82a307bcd4 100644 --- a/fs/Makefile +++ b/fs/Makefile | |||
@@ -51,11 +51,7 @@ obj-$(CONFIG_FS_POSIX_ACL) += posix_acl.o xattr_acl.o | |||
51 | obj-$(CONFIG_NFS_COMMON) += nfs_common/ | 51 | obj-$(CONFIG_NFS_COMMON) += nfs_common/ |
52 | obj-$(CONFIG_GENERIC_ACL) += generic_acl.o | 52 | obj-$(CONFIG_GENERIC_ACL) += generic_acl.o |
53 | 53 | ||
54 | obj-$(CONFIG_QUOTA) += dquot.o | 54 | obj-y += quota/ |
55 | obj-$(CONFIG_QFMT_V1) += quota_v1.o | ||
56 | obj-$(CONFIG_QFMT_V2) += quota_v2.o | ||
57 | obj-$(CONFIG_QUOTA_TREE) += quota_tree.o | ||
58 | obj-$(CONFIG_QUOTACTL) += quota.o | ||
59 | 55 | ||
60 | obj-$(CONFIG_PROC_FS) += proc/ | 56 | obj-$(CONFIG_PROC_FS) += proc/ |
61 | obj-y += partitions/ | 57 | obj-y += partitions/ |
diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h index 831157502d5a..e0a85dbeeb88 100644 --- a/fs/adfs/adfs.h +++ b/fs/adfs/adfs.h | |||
@@ -86,7 +86,7 @@ void __adfs_error(struct super_block *sb, const char *function, | |||
86 | /* dir_*.c */ | 86 | /* dir_*.c */ |
87 | extern const struct inode_operations adfs_dir_inode_operations; | 87 | extern const struct inode_operations adfs_dir_inode_operations; |
88 | extern const struct file_operations adfs_dir_operations; | 88 | extern const struct file_operations adfs_dir_operations; |
89 | extern struct dentry_operations adfs_dentry_operations; | 89 | extern const struct dentry_operations adfs_dentry_operations; |
90 | extern struct adfs_dir_ops adfs_f_dir_ops; | 90 | extern struct adfs_dir_ops adfs_f_dir_ops; |
91 | extern struct adfs_dir_ops adfs_fplus_dir_ops; | 91 | extern struct adfs_dir_ops adfs_fplus_dir_ops; |
92 | 92 | ||
diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c index 85a30e929800..e867ccf37246 100644 --- a/fs/adfs/dir.c +++ b/fs/adfs/dir.c | |||
@@ -263,7 +263,7 @@ adfs_compare(struct dentry *parent, struct qstr *entry, struct qstr *name) | |||
263 | return 0; | 263 | return 0; |
264 | } | 264 | } |
265 | 265 | ||
266 | struct dentry_operations adfs_dentry_operations = { | 266 | const struct dentry_operations adfs_dentry_operations = { |
267 | .d_hash = adfs_hash, | 267 | .d_hash = adfs_hash, |
268 | .d_compare = adfs_compare, | 268 | .d_compare = adfs_compare, |
269 | }; | 269 | }; |
diff --git a/fs/affs/affs.h b/fs/affs/affs.h index e9ec915f7553..1a2d5e3c7f4e 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h | |||
@@ -199,8 +199,7 @@ extern const struct address_space_operations affs_symlink_aops; | |||
199 | extern const struct address_space_operations affs_aops; | 199 | extern const struct address_space_operations affs_aops; |
200 | extern const struct address_space_operations affs_aops_ofs; | 200 | extern const struct address_space_operations affs_aops_ofs; |
201 | 201 | ||
202 | extern struct dentry_operations affs_dentry_operations; | 202 | extern const struct dentry_operations affs_dentry_operations; |
203 | extern struct dentry_operations affs_dentry_operations_intl; | ||
204 | 203 | ||
205 | static inline void | 204 | static inline void |
206 | affs_set_blocksize(struct super_block *sb, int size) | 205 | affs_set_blocksize(struct super_block *sb, int size) |
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c index 805573005de6..7d0f0a30f7a3 100644 --- a/fs/affs/amigaffs.c +++ b/fs/affs/amigaffs.c | |||
@@ -179,14 +179,18 @@ affs_remove_link(struct dentry *dentry) | |||
179 | affs_lock_dir(dir); | 179 | affs_lock_dir(dir); |
180 | affs_fix_dcache(dentry, link_ino); | 180 | affs_fix_dcache(dentry, link_ino); |
181 | retval = affs_remove_hash(dir, link_bh); | 181 | retval = affs_remove_hash(dir, link_bh); |
182 | if (retval) | 182 | if (retval) { |
183 | affs_unlock_dir(dir); | ||
183 | goto done; | 184 | goto done; |
185 | } | ||
184 | mark_buffer_dirty_inode(link_bh, inode); | 186 | mark_buffer_dirty_inode(link_bh, inode); |
185 | 187 | ||
186 | memcpy(AFFS_TAIL(sb, bh)->name, AFFS_TAIL(sb, link_bh)->name, 32); | 188 | memcpy(AFFS_TAIL(sb, bh)->name, AFFS_TAIL(sb, link_bh)->name, 32); |
187 | retval = affs_insert_hash(dir, bh); | 189 | retval = affs_insert_hash(dir, bh); |
188 | if (retval) | 190 | if (retval) { |
191 | affs_unlock_dir(dir); | ||
189 | goto done; | 192 | goto done; |
193 | } | ||
190 | mark_buffer_dirty_inode(bh, inode); | 194 | mark_buffer_dirty_inode(bh, inode); |
191 | 195 | ||
192 | affs_unlock_dir(dir); | 196 | affs_unlock_dir(dir); |
diff --git a/fs/affs/namei.c b/fs/affs/namei.c index cfcf1b6cf82b..960d336ec694 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c | |||
@@ -19,12 +19,12 @@ static int affs_intl_toupper(int ch); | |||
19 | static int affs_intl_hash_dentry(struct dentry *, struct qstr *); | 19 | static int affs_intl_hash_dentry(struct dentry *, struct qstr *); |
20 | static int affs_intl_compare_dentry(struct dentry *, struct qstr *, struct qstr *); | 20 | static int affs_intl_compare_dentry(struct dentry *, struct qstr *, struct qstr *); |
21 | 21 | ||
22 | struct dentry_operations affs_dentry_operations = { | 22 | const struct dentry_operations affs_dentry_operations = { |
23 | .d_hash = affs_hash_dentry, | 23 | .d_hash = affs_hash_dentry, |
24 | .d_compare = affs_compare_dentry, | 24 | .d_compare = affs_compare_dentry, |
25 | }; | 25 | }; |
26 | 26 | ||
27 | static struct dentry_operations affs_intl_dentry_operations = { | 27 | static const struct dentry_operations affs_intl_dentry_operations = { |
28 | .d_hash = affs_intl_hash_dentry, | 28 | .d_hash = affs_intl_hash_dentry, |
29 | .d_compare = affs_intl_compare_dentry, | 29 | .d_compare = affs_intl_compare_dentry, |
30 | }; | 30 | }; |
diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 99cf390641f7..9bd757774c9e 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c | |||
@@ -62,7 +62,7 @@ const struct inode_operations afs_dir_inode_operations = { | |||
62 | .setattr = afs_setattr, | 62 | .setattr = afs_setattr, |
63 | }; | 63 | }; |
64 | 64 | ||
65 | static struct dentry_operations afs_fs_dentry_operations = { | 65 | static const struct dentry_operations afs_fs_dentry_operations = { |
66 | .d_revalidate = afs_d_revalidate, | 66 | .d_revalidate = afs_d_revalidate, |
67 | .d_delete = afs_d_delete, | 67 | .d_delete = afs_d_delete, |
68 | .d_release = afs_d_release, | 68 | .d_release = afs_d_release, |
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c index 3bbdb9d02376..1dd96d4406c0 100644 --- a/fs/anon_inodes.c +++ b/fs/anon_inodes.c | |||
@@ -48,7 +48,7 @@ static struct file_system_type anon_inode_fs_type = { | |||
48 | .get_sb = anon_inodefs_get_sb, | 48 | .get_sb = anon_inodefs_get_sb, |
49 | .kill_sb = kill_anon_super, | 49 | .kill_sb = kill_anon_super, |
50 | }; | 50 | }; |
51 | static struct dentry_operations anon_inodefs_dentry_operations = { | 51 | static const struct dentry_operations anon_inodefs_dentry_operations = { |
52 | .d_delete = anon_inodefs_delete_dentry, | 52 | .d_delete = anon_inodefs_delete_dentry, |
53 | }; | 53 | }; |
54 | 54 | ||
@@ -173,7 +173,8 @@ int notify_change(struct dentry * dentry, struct iattr * attr) | |||
173 | if (!error) { | 173 | if (!error) { |
174 | if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || | 174 | if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
175 | (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) | 175 | (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) |
176 | error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0; | 176 | error = vfs_dq_transfer(inode, attr) ? |
177 | -EDQUOT : 0; | ||
177 | if (!error) | 178 | if (!error) |
178 | error = inode_setattr(inode, attr); | 179 | error = inode_setattr(inode, attr); |
179 | } | 180 | } |
diff --git a/fs/autofs/root.c b/fs/autofs/root.c index 8aacade56956..4a1401cea0a1 100644 --- a/fs/autofs/root.c +++ b/fs/autofs/root.c | |||
@@ -192,7 +192,7 @@ static int autofs_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
192 | return 1; | 192 | return 1; |
193 | } | 193 | } |
194 | 194 | ||
195 | static struct dentry_operations autofs_dentry_operations = { | 195 | static const struct dentry_operations autofs_dentry_operations = { |
196 | .d_revalidate = autofs_revalidate, | 196 | .d_revalidate = autofs_revalidate, |
197 | }; | 197 | }; |
198 | 198 | ||
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c index 716e12b627b2..69c8142da838 100644 --- a/fs/autofs4/inode.c +++ b/fs/autofs4/inode.c | |||
@@ -310,7 +310,7 @@ static struct autofs_info *autofs4_mkroot(struct autofs_sb_info *sbi) | |||
310 | return ino; | 310 | return ino; |
311 | } | 311 | } |
312 | 312 | ||
313 | static struct dentry_operations autofs4_sb_dentry_operations = { | 313 | static const struct dentry_operations autofs4_sb_dentry_operations = { |
314 | .d_release = autofs4_dentry_release, | 314 | .d_release = autofs4_dentry_release, |
315 | }; | 315 | }; |
316 | 316 | ||
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index 2a41c2a7fc52..74b1469a9504 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
@@ -349,13 +349,13 @@ void autofs4_dentry_release(struct dentry *de) | |||
349 | } | 349 | } |
350 | 350 | ||
351 | /* For dentries of directories in the root dir */ | 351 | /* For dentries of directories in the root dir */ |
352 | static struct dentry_operations autofs4_root_dentry_operations = { | 352 | static const struct dentry_operations autofs4_root_dentry_operations = { |
353 | .d_revalidate = autofs4_revalidate, | 353 | .d_revalidate = autofs4_revalidate, |
354 | .d_release = autofs4_dentry_release, | 354 | .d_release = autofs4_dentry_release, |
355 | }; | 355 | }; |
356 | 356 | ||
357 | /* For other dentries */ | 357 | /* For other dentries */ |
358 | static struct dentry_operations autofs4_dentry_operations = { | 358 | static const struct dentry_operations autofs4_dentry_operations = { |
359 | .d_revalidate = autofs4_revalidate, | 359 | .d_revalidate = autofs4_revalidate, |
360 | .d_release = autofs4_dentry_release, | 360 | .d_release = autofs4_dentry_release, |
361 | }; | 361 | }; |
diff --git a/fs/block_dev.c b/fs/block_dev.c index b3c1efff5e1d..8c3c6899ccf3 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/blkpg.h> | 19 | #include <linux/blkpg.h> |
20 | #include <linux/buffer_head.h> | 20 | #include <linux/buffer_head.h> |
21 | #include <linux/pagevec.h> | ||
21 | #include <linux/writeback.h> | 22 | #include <linux/writeback.h> |
22 | #include <linux/mpage.h> | 23 | #include <linux/mpage.h> |
23 | #include <linux/mount.h> | 24 | #include <linux/mount.h> |
@@ -174,6 +175,151 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, | |||
174 | iov, offset, nr_segs, blkdev_get_blocks, NULL); | 175 | iov, offset, nr_segs, blkdev_get_blocks, NULL); |
175 | } | 176 | } |
176 | 177 | ||
178 | /* | ||
179 | * Write out and wait upon all the dirty data associated with a block | ||
180 | * device via its mapping. Does not take the superblock lock. | ||
181 | */ | ||
182 | int sync_blockdev(struct block_device *bdev) | ||
183 | { | ||
184 | int ret = 0; | ||
185 | |||
186 | if (bdev) | ||
187 | ret = filemap_write_and_wait(bdev->bd_inode->i_mapping); | ||
188 | return ret; | ||
189 | } | ||
190 | EXPORT_SYMBOL(sync_blockdev); | ||
191 | |||
192 | /* | ||
193 | * Write out and wait upon all dirty data associated with this | ||
194 | * device. Filesystem data as well as the underlying block | ||
195 | * device. Takes the superblock lock. | ||
196 | */ | ||
197 | int fsync_bdev(struct block_device *bdev) | ||
198 | { | ||
199 | struct super_block *sb = get_super(bdev); | ||
200 | if (sb) { | ||
201 | int res = fsync_super(sb); | ||
202 | drop_super(sb); | ||
203 | return res; | ||
204 | } | ||
205 | return sync_blockdev(bdev); | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * freeze_bdev -- lock a filesystem and force it into a consistent state | ||
210 | * @bdev: blockdevice to lock | ||
211 | * | ||
212 | * This takes the block device bd_mount_sem to make sure no new mounts | ||
213 | * happen on bdev until thaw_bdev() is called. | ||
214 | * If a superblock is found on this device, we take the s_umount semaphore | ||
215 | * on it to make sure nobody unmounts until the snapshot creation is done. | ||
216 | * The reference counter (bd_fsfreeze_count) guarantees that only the last | ||
217 | * unfreeze process can unfreeze the frozen filesystem actually when multiple | ||
218 | * freeze requests arrive simultaneously. It counts up in freeze_bdev() and | ||
219 | * count down in thaw_bdev(). When it becomes 0, thaw_bdev() will unfreeze | ||
220 | * actually. | ||
221 | */ | ||
222 | struct super_block *freeze_bdev(struct block_device *bdev) | ||
223 | { | ||
224 | struct super_block *sb; | ||
225 | int error = 0; | ||
226 | |||
227 | mutex_lock(&bdev->bd_fsfreeze_mutex); | ||
228 | if (bdev->bd_fsfreeze_count > 0) { | ||
229 | bdev->bd_fsfreeze_count++; | ||
230 | sb = get_super(bdev); | ||
231 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
232 | return sb; | ||
233 | } | ||
234 | bdev->bd_fsfreeze_count++; | ||
235 | |||
236 | down(&bdev->bd_mount_sem); | ||
237 | sb = get_super(bdev); | ||
238 | if (sb && !(sb->s_flags & MS_RDONLY)) { | ||
239 | sb->s_frozen = SB_FREEZE_WRITE; | ||
240 | smp_wmb(); | ||
241 | |||
242 | __fsync_super(sb); | ||
243 | |||
244 | sb->s_frozen = SB_FREEZE_TRANS; | ||
245 | smp_wmb(); | ||
246 | |||
247 | sync_blockdev(sb->s_bdev); | ||
248 | |||
249 | if (sb->s_op->freeze_fs) { | ||
250 | error = sb->s_op->freeze_fs(sb); | ||
251 | if (error) { | ||
252 | printk(KERN_ERR | ||
253 | "VFS:Filesystem freeze failed\n"); | ||
254 | sb->s_frozen = SB_UNFROZEN; | ||
255 | drop_super(sb); | ||
256 | up(&bdev->bd_mount_sem); | ||
257 | bdev->bd_fsfreeze_count--; | ||
258 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
259 | return ERR_PTR(error); | ||
260 | } | ||
261 | } | ||
262 | } | ||
263 | |||
264 | sync_blockdev(bdev); | ||
265 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
266 | |||
267 | return sb; /* thaw_bdev releases s->s_umount and bd_mount_sem */ | ||
268 | } | ||
269 | EXPORT_SYMBOL(freeze_bdev); | ||
270 | |||
271 | /** | ||
272 | * thaw_bdev -- unlock filesystem | ||
273 | * @bdev: blockdevice to unlock | ||
274 | * @sb: associated superblock | ||
275 | * | ||
276 | * Unlocks the filesystem and marks it writeable again after freeze_bdev(). | ||
277 | */ | ||
278 | int thaw_bdev(struct block_device *bdev, struct super_block *sb) | ||
279 | { | ||
280 | int error = 0; | ||
281 | |||
282 | mutex_lock(&bdev->bd_fsfreeze_mutex); | ||
283 | if (!bdev->bd_fsfreeze_count) { | ||
284 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
285 | return -EINVAL; | ||
286 | } | ||
287 | |||
288 | bdev->bd_fsfreeze_count--; | ||
289 | if (bdev->bd_fsfreeze_count > 0) { | ||
290 | if (sb) | ||
291 | drop_super(sb); | ||
292 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | if (sb) { | ||
297 | BUG_ON(sb->s_bdev != bdev); | ||
298 | if (!(sb->s_flags & MS_RDONLY)) { | ||
299 | if (sb->s_op->unfreeze_fs) { | ||
300 | error = sb->s_op->unfreeze_fs(sb); | ||
301 | if (error) { | ||
302 | printk(KERN_ERR | ||
303 | "VFS:Filesystem thaw failed\n"); | ||
304 | sb->s_frozen = SB_FREEZE_TRANS; | ||
305 | bdev->bd_fsfreeze_count++; | ||
306 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
307 | return error; | ||
308 | } | ||
309 | } | ||
310 | sb->s_frozen = SB_UNFROZEN; | ||
311 | smp_wmb(); | ||
312 | wake_up(&sb->s_wait_unfrozen); | ||
313 | } | ||
314 | drop_super(sb); | ||
315 | } | ||
316 | |||
317 | up(&bdev->bd_mount_sem); | ||
318 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
319 | return 0; | ||
320 | } | ||
321 | EXPORT_SYMBOL(thaw_bdev); | ||
322 | |||
177 | static int blkdev_writepage(struct page *page, struct writeback_control *wbc) | 323 | static int blkdev_writepage(struct page *page, struct writeback_control *wbc) |
178 | { | 324 | { |
179 | return block_write_full_page(page, blkdev_get_block, wbc); | 325 | return block_write_full_page(page, blkdev_get_block, wbc); |
diff --git a/fs/buffer.c b/fs/buffer.c index 891e1c78e4f1..a2fd743d97cb 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -166,151 +166,6 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate) | |||
166 | } | 166 | } |
167 | 167 | ||
168 | /* | 168 | /* |
169 | * Write out and wait upon all the dirty data associated with a block | ||
170 | * device via its mapping. Does not take the superblock lock. | ||
171 | */ | ||
172 | int sync_blockdev(struct block_device *bdev) | ||
173 | { | ||
174 | int ret = 0; | ||
175 | |||
176 | if (bdev) | ||
177 | ret = filemap_write_and_wait(bdev->bd_inode->i_mapping); | ||
178 | return ret; | ||
179 | } | ||
180 | EXPORT_SYMBOL(sync_blockdev); | ||
181 | |||
182 | /* | ||
183 | * Write out and wait upon all dirty data associated with this | ||
184 | * device. Filesystem data as well as the underlying block | ||
185 | * device. Takes the superblock lock. | ||
186 | */ | ||
187 | int fsync_bdev(struct block_device *bdev) | ||
188 | { | ||
189 | struct super_block *sb = get_super(bdev); | ||
190 | if (sb) { | ||
191 | int res = fsync_super(sb); | ||
192 | drop_super(sb); | ||
193 | return res; | ||
194 | } | ||
195 | return sync_blockdev(bdev); | ||
196 | } | ||
197 | |||
198 | /** | ||
199 | * freeze_bdev -- lock a filesystem and force it into a consistent state | ||
200 | * @bdev: blockdevice to lock | ||
201 | * | ||
202 | * This takes the block device bd_mount_sem to make sure no new mounts | ||
203 | * happen on bdev until thaw_bdev() is called. | ||
204 | * If a superblock is found on this device, we take the s_umount semaphore | ||
205 | * on it to make sure nobody unmounts until the snapshot creation is done. | ||
206 | * The reference counter (bd_fsfreeze_count) guarantees that only the last | ||
207 | * unfreeze process can unfreeze the frozen filesystem actually when multiple | ||
208 | * freeze requests arrive simultaneously. It counts up in freeze_bdev() and | ||
209 | * count down in thaw_bdev(). When it becomes 0, thaw_bdev() will unfreeze | ||
210 | * actually. | ||
211 | */ | ||
212 | struct super_block *freeze_bdev(struct block_device *bdev) | ||
213 | { | ||
214 | struct super_block *sb; | ||
215 | int error = 0; | ||
216 | |||
217 | mutex_lock(&bdev->bd_fsfreeze_mutex); | ||
218 | if (bdev->bd_fsfreeze_count > 0) { | ||
219 | bdev->bd_fsfreeze_count++; | ||
220 | sb = get_super(bdev); | ||
221 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
222 | return sb; | ||
223 | } | ||
224 | bdev->bd_fsfreeze_count++; | ||
225 | |||
226 | down(&bdev->bd_mount_sem); | ||
227 | sb = get_super(bdev); | ||
228 | if (sb && !(sb->s_flags & MS_RDONLY)) { | ||
229 | sb->s_frozen = SB_FREEZE_WRITE; | ||
230 | smp_wmb(); | ||
231 | |||
232 | __fsync_super(sb); | ||
233 | |||
234 | sb->s_frozen = SB_FREEZE_TRANS; | ||
235 | smp_wmb(); | ||
236 | |||
237 | sync_blockdev(sb->s_bdev); | ||
238 | |||
239 | if (sb->s_op->freeze_fs) { | ||
240 | error = sb->s_op->freeze_fs(sb); | ||
241 | if (error) { | ||
242 | printk(KERN_ERR | ||
243 | "VFS:Filesystem freeze failed\n"); | ||
244 | sb->s_frozen = SB_UNFROZEN; | ||
245 | drop_super(sb); | ||
246 | up(&bdev->bd_mount_sem); | ||
247 | bdev->bd_fsfreeze_count--; | ||
248 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
249 | return ERR_PTR(error); | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | |||
254 | sync_blockdev(bdev); | ||
255 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
256 | |||
257 | return sb; /* thaw_bdev releases s->s_umount and bd_mount_sem */ | ||
258 | } | ||
259 | EXPORT_SYMBOL(freeze_bdev); | ||
260 | |||
261 | /** | ||
262 | * thaw_bdev -- unlock filesystem | ||
263 | * @bdev: blockdevice to unlock | ||
264 | * @sb: associated superblock | ||
265 | * | ||
266 | * Unlocks the filesystem and marks it writeable again after freeze_bdev(). | ||
267 | */ | ||
268 | int thaw_bdev(struct block_device *bdev, struct super_block *sb) | ||
269 | { | ||
270 | int error = 0; | ||
271 | |||
272 | mutex_lock(&bdev->bd_fsfreeze_mutex); | ||
273 | if (!bdev->bd_fsfreeze_count) { | ||
274 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
275 | return -EINVAL; | ||
276 | } | ||
277 | |||
278 | bdev->bd_fsfreeze_count--; | ||
279 | if (bdev->bd_fsfreeze_count > 0) { | ||
280 | if (sb) | ||
281 | drop_super(sb); | ||
282 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | if (sb) { | ||
287 | BUG_ON(sb->s_bdev != bdev); | ||
288 | if (!(sb->s_flags & MS_RDONLY)) { | ||
289 | if (sb->s_op->unfreeze_fs) { | ||
290 | error = sb->s_op->unfreeze_fs(sb); | ||
291 | if (error) { | ||
292 | printk(KERN_ERR | ||
293 | "VFS:Filesystem thaw failed\n"); | ||
294 | sb->s_frozen = SB_FREEZE_TRANS; | ||
295 | bdev->bd_fsfreeze_count++; | ||
296 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
297 | return error; | ||
298 | } | ||
299 | } | ||
300 | sb->s_frozen = SB_UNFROZEN; | ||
301 | smp_wmb(); | ||
302 | wake_up(&sb->s_wait_unfrozen); | ||
303 | } | ||
304 | drop_super(sb); | ||
305 | } | ||
306 | |||
307 | up(&bdev->bd_mount_sem); | ||
308 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | ||
309 | return 0; | ||
310 | } | ||
311 | EXPORT_SYMBOL(thaw_bdev); | ||
312 | |||
313 | /* | ||
314 | * Various filesystems appear to want __find_get_block to be non-blocking. | 169 | * Various filesystems appear to want __find_get_block to be non-blocking. |
315 | * But it's the page lock which protects the buffers. To get around this, | 170 | * But it's the page lock which protects the buffers. To get around this, |
316 | * we get exclusion from try_to_free_buffers with the blockdev mapping's | 171 | * we get exclusion from try_to_free_buffers with the blockdev mapping's |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 13ea53251dcf..38491fd3871d 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -606,7 +606,8 @@ cifs_get_sb(struct file_system_type *fs_type, | |||
606 | return rc; | 606 | return rc; |
607 | } | 607 | } |
608 | sb->s_flags |= MS_ACTIVE; | 608 | sb->s_flags |= MS_ACTIVE; |
609 | return simple_set_mnt(mnt, sb); | 609 | simple_set_mnt(mnt, sb); |
610 | return 0; | ||
610 | } | 611 | } |
611 | 612 | ||
612 | static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | 613 | static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, |
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 2b1d28a9ee28..77e190dc2883 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h | |||
@@ -78,8 +78,8 @@ extern int cifs_dir_open(struct inode *inode, struct file *file); | |||
78 | extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir); | 78 | extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir); |
79 | 79 | ||
80 | /* Functions related to dir entries */ | 80 | /* Functions related to dir entries */ |
81 | extern struct dentry_operations cifs_dentry_ops; | 81 | extern const struct dentry_operations cifs_dentry_ops; |
82 | extern struct dentry_operations cifs_ci_dentry_ops; | 82 | extern const struct dentry_operations cifs_ci_dentry_ops; |
83 | 83 | ||
84 | /* Functions related to symlinks */ | 84 | /* Functions related to symlinks */ |
85 | extern void *cifs_follow_link(struct dentry *direntry, struct nameidata *nd); | 85 | extern void *cifs_follow_link(struct dentry *direntry, struct nameidata *nd); |
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index f9b6f68be976..2f35cccfcd8d 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -701,7 +701,7 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd) | |||
701 | return rc; | 701 | return rc; |
702 | } */ | 702 | } */ |
703 | 703 | ||
704 | struct dentry_operations cifs_dentry_ops = { | 704 | const struct dentry_operations cifs_dentry_ops = { |
705 | .d_revalidate = cifs_d_revalidate, | 705 | .d_revalidate = cifs_d_revalidate, |
706 | /* d_delete: cifs_d_delete, */ /* not needed except for debugging */ | 706 | /* d_delete: cifs_d_delete, */ /* not needed except for debugging */ |
707 | }; | 707 | }; |
@@ -739,7 +739,7 @@ static int cifs_ci_compare(struct dentry *dentry, struct qstr *a, | |||
739 | return 1; | 739 | return 1; |
740 | } | 740 | } |
741 | 741 | ||
742 | struct dentry_operations cifs_ci_dentry_ops = { | 742 | const struct dentry_operations cifs_ci_dentry_ops = { |
743 | .d_revalidate = cifs_d_revalidate, | 743 | .d_revalidate = cifs_d_revalidate, |
744 | .d_hash = cifs_ci_hash, | 744 | .d_hash = cifs_ci_hash, |
745 | .d_compare = cifs_ci_compare, | 745 | .d_compare = cifs_ci_compare, |
diff --git a/fs/coda/dir.c b/fs/coda/dir.c index 75b1fa90b2cb..4bb9d0a5decc 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c | |||
@@ -59,7 +59,7 @@ static int coda_return_EIO(void) | |||
59 | } | 59 | } |
60 | #define CODA_EIO_ERROR ((void *) (coda_return_EIO)) | 60 | #define CODA_EIO_ERROR ((void *) (coda_return_EIO)) |
61 | 61 | ||
62 | static struct dentry_operations coda_dentry_operations = | 62 | static const struct dentry_operations coda_dentry_operations = |
63 | { | 63 | { |
64 | .d_revalidate = coda_dentry_revalidate, | 64 | .d_revalidate = coda_dentry_revalidate, |
65 | .d_delete = coda_dentry_delete, | 65 | .d_delete = coda_dentry_delete, |
diff --git a/fs/compat.c b/fs/compat.c index 0949b43794a4..5e374aad33f7 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -378,6 +378,34 @@ out: | |||
378 | return error; | 378 | return error; |
379 | } | 379 | } |
380 | 380 | ||
381 | /* | ||
382 | * This is a copy of sys_ustat, just dealing with a structure layout. | ||
383 | * Given how simple this syscall is that apporach is more maintainable | ||
384 | * than the various conversion hacks. | ||
385 | */ | ||
386 | asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u) | ||
387 | { | ||
388 | struct super_block *sb; | ||
389 | struct compat_ustat tmp; | ||
390 | struct kstatfs sbuf; | ||
391 | int err; | ||
392 | |||
393 | sb = user_get_super(new_decode_dev(dev)); | ||
394 | if (!sb) | ||
395 | return -EINVAL; | ||
396 | err = vfs_statfs(sb->s_root, &sbuf); | ||
397 | drop_super(sb); | ||
398 | if (err) | ||
399 | return err; | ||
400 | |||
401 | memset(&tmp, 0, sizeof(struct compat_ustat)); | ||
402 | tmp.f_tfree = sbuf.f_bfree; | ||
403 | tmp.f_tinode = sbuf.f_ffree; | ||
404 | if (copy_to_user(u, &tmp, sizeof(struct compat_ustat))) | ||
405 | return -EFAULT; | ||
406 | return 0; | ||
407 | } | ||
408 | |||
381 | static int get_compat_flock(struct flock *kfl, struct compat_flock __user *ufl) | 409 | static int get_compat_flock(struct flock *kfl, struct compat_flock __user *ufl) |
382 | { | 410 | { |
383 | if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) || | 411 | if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) || |
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 8e93341f3e82..05373db21a4e 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -72,7 +72,7 @@ static int configfs_d_delete(struct dentry *dentry) | |||
72 | return 1; | 72 | return 1; |
73 | } | 73 | } |
74 | 74 | ||
75 | static struct dentry_operations configfs_dentry_ops = { | 75 | static const struct dentry_operations configfs_dentry_ops = { |
76 | .d_iput = configfs_d_iput, | 76 | .d_iput = configfs_d_iput, |
77 | /* simple_delete_dentry() isn't exported */ | 77 | /* simple_delete_dentry() isn't exported */ |
78 | .d_delete = configfs_d_delete, | 78 | .d_delete = configfs_d_delete, |
diff --git a/fs/dcache.c b/fs/dcache.c index 07e2d4a44bda..90bbd7e1b116 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -1247,15 +1247,18 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, | |||
1247 | struct dentry *found; | 1247 | struct dentry *found; |
1248 | struct dentry *new; | 1248 | struct dentry *new; |
1249 | 1249 | ||
1250 | /* Does a dentry matching the name exist already? */ | 1250 | /* |
1251 | * First check if a dentry matching the name already exists, | ||
1252 | * if not go ahead and create it now. | ||
1253 | */ | ||
1251 | found = d_hash_and_lookup(dentry->d_parent, name); | 1254 | found = d_hash_and_lookup(dentry->d_parent, name); |
1252 | /* If not, create it now and return */ | ||
1253 | if (!found) { | 1255 | if (!found) { |
1254 | new = d_alloc(dentry->d_parent, name); | 1256 | new = d_alloc(dentry->d_parent, name); |
1255 | if (!new) { | 1257 | if (!new) { |
1256 | error = -ENOMEM; | 1258 | error = -ENOMEM; |
1257 | goto err_out; | 1259 | goto err_out; |
1258 | } | 1260 | } |
1261 | |||
1259 | found = d_splice_alias(inode, new); | 1262 | found = d_splice_alias(inode, new); |
1260 | if (found) { | 1263 | if (found) { |
1261 | dput(new); | 1264 | dput(new); |
@@ -1263,61 +1266,46 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, | |||
1263 | } | 1266 | } |
1264 | return new; | 1267 | return new; |
1265 | } | 1268 | } |
1266 | /* Matching dentry exists, check if it is negative. */ | 1269 | |
1270 | /* | ||
1271 | * If a matching dentry exists, and it's not negative use it. | ||
1272 | * | ||
1273 | * Decrement the reference count to balance the iget() done | ||
1274 | * earlier on. | ||
1275 | */ | ||
1267 | if (found->d_inode) { | 1276 | if (found->d_inode) { |
1268 | if (unlikely(found->d_inode != inode)) { | 1277 | if (unlikely(found->d_inode != inode)) { |
1269 | /* This can't happen because bad inodes are unhashed. */ | 1278 | /* This can't happen because bad inodes are unhashed. */ |
1270 | BUG_ON(!is_bad_inode(inode)); | 1279 | BUG_ON(!is_bad_inode(inode)); |
1271 | BUG_ON(!is_bad_inode(found->d_inode)); | 1280 | BUG_ON(!is_bad_inode(found->d_inode)); |
1272 | } | 1281 | } |
1273 | /* | ||
1274 | * Already have the inode and the dentry attached, decrement | ||
1275 | * the reference count to balance the iget() done | ||
1276 | * earlier on. We found the dentry using d_lookup() so it | ||
1277 | * cannot be disconnected and thus we do not need to worry | ||
1278 | * about any NFS/disconnectedness issues here. | ||
1279 | */ | ||
1280 | iput(inode); | 1282 | iput(inode); |
1281 | return found; | 1283 | return found; |
1282 | } | 1284 | } |
1285 | |||
1283 | /* | 1286 | /* |
1284 | * Negative dentry: instantiate it unless the inode is a directory and | 1287 | * Negative dentry: instantiate it unless the inode is a directory and |
1285 | * has a 'disconnected' dentry (i.e. IS_ROOT and DCACHE_DISCONNECTED), | 1288 | * already has a dentry. |
1286 | * in which case d_move() that in place of the found dentry. | ||
1287 | */ | 1289 | */ |
1288 | if (!S_ISDIR(inode->i_mode)) { | ||
1289 | /* Not a directory; everything is easy. */ | ||
1290 | d_instantiate(found, inode); | ||
1291 | return found; | ||
1292 | } | ||
1293 | spin_lock(&dcache_lock); | 1290 | spin_lock(&dcache_lock); |
1294 | if (list_empty(&inode->i_dentry)) { | 1291 | if (!S_ISDIR(inode->i_mode) || list_empty(&inode->i_dentry)) { |
1295 | /* | ||
1296 | * Directory without a 'disconnected' dentry; we need to do | ||
1297 | * d_instantiate() by hand because it takes dcache_lock which | ||
1298 | * we already hold. | ||
1299 | */ | ||
1300 | __d_instantiate(found, inode); | 1292 | __d_instantiate(found, inode); |
1301 | spin_unlock(&dcache_lock); | 1293 | spin_unlock(&dcache_lock); |
1302 | security_d_instantiate(found, inode); | 1294 | security_d_instantiate(found, inode); |
1303 | return found; | 1295 | return found; |
1304 | } | 1296 | } |
1297 | |||
1305 | /* | 1298 | /* |
1306 | * Directory with a 'disconnected' dentry; get a reference to the | 1299 | * In case a directory already has a (disconnected) entry grab a |
1307 | * 'disconnected' dentry. | 1300 | * reference to it, move it in place and use it. |
1308 | */ | 1301 | */ |
1309 | new = list_entry(inode->i_dentry.next, struct dentry, d_alias); | 1302 | new = list_entry(inode->i_dentry.next, struct dentry, d_alias); |
1310 | dget_locked(new); | 1303 | dget_locked(new); |
1311 | spin_unlock(&dcache_lock); | 1304 | spin_unlock(&dcache_lock); |
1312 | /* Do security vodoo. */ | ||
1313 | security_d_instantiate(found, inode); | 1305 | security_d_instantiate(found, inode); |
1314 | /* Move new in place of found. */ | ||
1315 | d_move(new, found); | 1306 | d_move(new, found); |
1316 | /* Balance the iget() we did above. */ | ||
1317 | iput(inode); | 1307 | iput(inode); |
1318 | /* Throw away found. */ | ||
1319 | dput(found); | 1308 | dput(found); |
1320 | /* Use new as the actual dentry. */ | ||
1321 | return new; | 1309 | return new; |
1322 | 1310 | ||
1323 | err_out: | 1311 | err_out: |
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index bff4052b05e7..63a4a59e4148 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
@@ -322,177 +322,81 @@ static int compare_init_pts_sb(struct super_block *s, void *p) | |||
322 | } | 322 | } |
323 | 323 | ||
324 | /* | 324 | /* |
325 | * Safely parse the mount options in @data and update @opts. | 325 | * devpts_get_sb() |
326 | * | 326 | * |
327 | * devpts ends up parsing options two times during mount, due to the | 327 | * If the '-o newinstance' mount option was specified, mount a new |
328 | * two modes of operation it supports. The first parse occurs in | 328 | * (private) instance of devpts. PTYs created in this instance are |
329 | * devpts_get_sb() when determining the mode (single-instance or | 329 | * independent of the PTYs in other devpts instances. |
330 | * multi-instance mode). The second parse happens in devpts_remount() | ||
331 | * or new_pts_mount() depending on the mode. | ||
332 | * | 330 | * |
333 | * Parsing of options modifies the @data making subsequent parsing | 331 | * If the '-o newinstance' option was not specified, mount/remount the |
334 | * incorrect. So make a local copy of @data and parse it. | 332 | * initial kernel mount of devpts. This type of mount gives the |
333 | * legacy, single-instance semantics. | ||
335 | * | 334 | * |
336 | * Return: 0 On success, -errno on error | 335 | * The 'newinstance' option is needed to support multiple namespace |
337 | */ | 336 | * semantics in devpts while preserving backward compatibility of the |
338 | static int safe_parse_mount_options(void *data, struct pts_mount_opts *opts) | 337 | * current 'single-namespace' semantics. i.e all mounts of devpts |
339 | { | 338 | * without the 'newinstance' mount option should bind to the initial |
340 | int rc; | 339 | * kernel mount, like get_sb_single(). |
341 | void *datacp; | ||
342 | |||
343 | if (!data) | ||
344 | return 0; | ||
345 | |||
346 | /* Use kstrdup() ? */ | ||
347 | datacp = kmalloc(PAGE_SIZE, GFP_KERNEL); | ||
348 | if (!datacp) | ||
349 | return -ENOMEM; | ||
350 | |||
351 | memcpy(datacp, data, PAGE_SIZE); | ||
352 | rc = parse_mount_options((char *)datacp, PARSE_MOUNT, opts); | ||
353 | kfree(datacp); | ||
354 | |||
355 | return rc; | ||
356 | } | ||
357 | |||
358 | /* | ||
359 | * Mount a new (private) instance of devpts. PTYs created in this | ||
360 | * instance are independent of the PTYs in other devpts instances. | ||
361 | */ | ||
362 | static int new_pts_mount(struct file_system_type *fs_type, int flags, | ||
363 | void *data, struct vfsmount *mnt) | ||
364 | { | ||
365 | int err; | ||
366 | struct pts_fs_info *fsi; | ||
367 | struct pts_mount_opts *opts; | ||
368 | |||
369 | err = get_sb_nodev(fs_type, flags, data, devpts_fill_super, mnt); | ||
370 | if (err) | ||
371 | return err; | ||
372 | |||
373 | fsi = DEVPTS_SB(mnt->mnt_sb); | ||
374 | opts = &fsi->mount_opts; | ||
375 | |||
376 | err = parse_mount_options(data, PARSE_MOUNT, opts); | ||
377 | if (err) | ||
378 | goto fail; | ||
379 | |||
380 | err = mknod_ptmx(mnt->mnt_sb); | ||
381 | if (err) | ||
382 | goto fail; | ||
383 | |||
384 | return 0; | ||
385 | |||
386 | fail: | ||
387 | dput(mnt->mnt_sb->s_root); | ||
388 | deactivate_super(mnt->mnt_sb); | ||
389 | return err; | ||
390 | } | ||
391 | |||
392 | /* | ||
393 | * Check if 'newinstance' mount option was specified in @data. | ||
394 | * | 340 | * |
395 | * Return: -errno on error (eg: invalid mount options specified) | 341 | * Mounts with 'newinstance' option create a new, private namespace. |
396 | * : 1 if 'newinstance' mount option was specified | ||
397 | * : 0 if 'newinstance' mount option was NOT specified | ||
398 | */ | ||
399 | static int is_new_instance_mount(void *data) | ||
400 | { | ||
401 | int rc; | ||
402 | struct pts_mount_opts opts; | ||
403 | |||
404 | if (!data) | ||
405 | return 0; | ||
406 | |||
407 | rc = safe_parse_mount_options(data, &opts); | ||
408 | if (!rc) | ||
409 | rc = opts.newinstance; | ||
410 | |||
411 | return rc; | ||
412 | } | ||
413 | |||
414 | /* | ||
415 | * get_init_pts_sb() | ||
416 | * | ||
417 | * This interface is needed to support multiple namespace semantics in | ||
418 | * devpts while preserving backward compatibility of the current 'single- | ||
419 | * namespace' semantics. i.e all mounts of devpts without the 'newinstance' | ||
420 | * mount option should bind to the initial kernel mount, like | ||
421 | * get_sb_single(). | ||
422 | * | 342 | * |
423 | * Mounts with 'newinstance' option create a new private namespace. | 343 | * NOTE: |
424 | * | 344 | * |
425 | * But for single-mount semantics, devpts cannot use get_sb_single(), | 345 | * For single-mount semantics, devpts cannot use get_sb_single(), |
426 | * because get_sb_single()/sget() find and use the super-block from | 346 | * because get_sb_single()/sget() find and use the super-block from |
427 | * the most recent mount of devpts. But that recent mount may be a | 347 | * the most recent mount of devpts. But that recent mount may be a |
428 | * 'newinstance' mount and get_sb_single() would pick the newinstance | 348 | * 'newinstance' mount and get_sb_single() would pick the newinstance |
429 | * super-block instead of the initial super-block. | 349 | * super-block instead of the initial super-block. |
430 | * | ||
431 | * This interface is identical to get_sb_single() except that it | ||
432 | * consistently selects the 'single-namespace' superblock even in the | ||
433 | * presence of the private namespace (i.e 'newinstance') super-blocks. | ||
434 | */ | 350 | */ |
435 | static int get_init_pts_sb(struct file_system_type *fs_type, int flags, | 351 | static int devpts_get_sb(struct file_system_type *fs_type, |
436 | void *data, struct vfsmount *mnt) | 352 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) |
437 | { | 353 | { |
438 | struct super_block *s; | ||
439 | int error; | 354 | int error; |
355 | struct pts_mount_opts opts; | ||
356 | struct super_block *s; | ||
357 | |||
358 | memset(&opts, 0, sizeof(opts)); | ||
359 | if (data) { | ||
360 | error = parse_mount_options(data, PARSE_MOUNT, &opts); | ||
361 | if (error) | ||
362 | return error; | ||
363 | } | ||
364 | |||
365 | if (opts.newinstance) | ||
366 | s = sget(fs_type, NULL, set_anon_super, NULL); | ||
367 | else | ||
368 | s = sget(fs_type, compare_init_pts_sb, set_anon_super, NULL); | ||
440 | 369 | ||
441 | s = sget(fs_type, compare_init_pts_sb, set_anon_super, NULL); | ||
442 | if (IS_ERR(s)) | 370 | if (IS_ERR(s)) |
443 | return PTR_ERR(s); | 371 | return PTR_ERR(s); |
444 | 372 | ||
445 | if (!s->s_root) { | 373 | if (!s->s_root) { |
446 | s->s_flags = flags; | 374 | s->s_flags = flags; |
447 | error = devpts_fill_super(s, data, flags & MS_SILENT ? 1 : 0); | 375 | error = devpts_fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
448 | if (error) { | 376 | if (error) |
449 | up_write(&s->s_umount); | 377 | goto out_undo_sget; |
450 | deactivate_super(s); | ||
451 | return error; | ||
452 | } | ||
453 | s->s_flags |= MS_ACTIVE; | 378 | s->s_flags |= MS_ACTIVE; |
454 | } | 379 | } |
455 | do_remount_sb(s, flags, data, 0); | ||
456 | return simple_set_mnt(mnt, s); | ||
457 | } | ||
458 | 380 | ||
459 | /* | 381 | simple_set_mnt(mnt, s); |
460 | * Mount or remount the initial kernel mount of devpts. This type of | ||
461 | * mount maintains the legacy, single-instance semantics, while the | ||
462 | * kernel still allows multiple-instances. | ||
463 | */ | ||
464 | static int init_pts_mount(struct file_system_type *fs_type, int flags, | ||
465 | void *data, struct vfsmount *mnt) | ||
466 | { | ||
467 | int err; | ||
468 | 382 | ||
469 | err = get_init_pts_sb(fs_type, flags, data, mnt); | 383 | memcpy(&(DEVPTS_SB(s))->mount_opts, &opts, sizeof(opts)); |
470 | if (err) | ||
471 | return err; | ||
472 | 384 | ||
473 | err = mknod_ptmx(mnt->mnt_sb); | 385 | error = mknod_ptmx(s); |
474 | if (err) { | 386 | if (error) |
475 | dput(mnt->mnt_sb->s_root); | 387 | goto out_dput; |
476 | deactivate_super(mnt->mnt_sb); | ||
477 | } | ||
478 | 388 | ||
479 | return err; | 389 | return 0; |
480 | } | ||
481 | |||
482 | static int devpts_get_sb(struct file_system_type *fs_type, | ||
483 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) | ||
484 | { | ||
485 | int new; | ||
486 | |||
487 | new = is_new_instance_mount(data); | ||
488 | if (new < 0) | ||
489 | return new; | ||
490 | 390 | ||
491 | if (new) | 391 | out_dput: |
492 | return new_pts_mount(fs_type, flags, data, mnt); | 392 | dput(s->s_root); |
493 | 393 | ||
494 | return init_pts_mount(fs_type, flags, data, mnt); | 394 | out_undo_sget: |
395 | up_write(&s->s_umount); | ||
396 | deactivate_super(s); | ||
397 | return error; | ||
495 | } | 398 | } |
399 | |||
496 | #else | 400 | #else |
497 | /* | 401 | /* |
498 | * This supports only the legacy single-instance semantics (no | 402 | * This supports only the legacy single-instance semantics (no |
diff --git a/fs/dlm/dir.c b/fs/dlm/dir.c index 92969f879a17..858fba14aaa6 100644 --- a/fs/dlm/dir.c +++ b/fs/dlm/dir.c | |||
@@ -156,7 +156,7 @@ void dlm_dir_remove_entry(struct dlm_ls *ls, int nodeid, char *name, int namelen | |||
156 | 156 | ||
157 | bucket = dir_hash(ls, name, namelen); | 157 | bucket = dir_hash(ls, name, namelen); |
158 | 158 | ||
159 | write_lock(&ls->ls_dirtbl[bucket].lock); | 159 | spin_lock(&ls->ls_dirtbl[bucket].lock); |
160 | 160 | ||
161 | de = search_bucket(ls, name, namelen, bucket); | 161 | de = search_bucket(ls, name, namelen, bucket); |
162 | 162 | ||
@@ -173,7 +173,7 @@ void dlm_dir_remove_entry(struct dlm_ls *ls, int nodeid, char *name, int namelen | |||
173 | list_del(&de->list); | 173 | list_del(&de->list); |
174 | kfree(de); | 174 | kfree(de); |
175 | out: | 175 | out: |
176 | write_unlock(&ls->ls_dirtbl[bucket].lock); | 176 | spin_unlock(&ls->ls_dirtbl[bucket].lock); |
177 | } | 177 | } |
178 | 178 | ||
179 | void dlm_dir_clear(struct dlm_ls *ls) | 179 | void dlm_dir_clear(struct dlm_ls *ls) |
@@ -185,14 +185,14 @@ void dlm_dir_clear(struct dlm_ls *ls) | |||
185 | DLM_ASSERT(list_empty(&ls->ls_recover_list), ); | 185 | DLM_ASSERT(list_empty(&ls->ls_recover_list), ); |
186 | 186 | ||
187 | for (i = 0; i < ls->ls_dirtbl_size; i++) { | 187 | for (i = 0; i < ls->ls_dirtbl_size; i++) { |
188 | write_lock(&ls->ls_dirtbl[i].lock); | 188 | spin_lock(&ls->ls_dirtbl[i].lock); |
189 | head = &ls->ls_dirtbl[i].list; | 189 | head = &ls->ls_dirtbl[i].list; |
190 | while (!list_empty(head)) { | 190 | while (!list_empty(head)) { |
191 | de = list_entry(head->next, struct dlm_direntry, list); | 191 | de = list_entry(head->next, struct dlm_direntry, list); |
192 | list_del(&de->list); | 192 | list_del(&de->list); |
193 | put_free_de(ls, de); | 193 | put_free_de(ls, de); |
194 | } | 194 | } |
195 | write_unlock(&ls->ls_dirtbl[i].lock); | 195 | spin_unlock(&ls->ls_dirtbl[i].lock); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
@@ -307,17 +307,17 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name, | |||
307 | 307 | ||
308 | bucket = dir_hash(ls, name, namelen); | 308 | bucket = dir_hash(ls, name, namelen); |
309 | 309 | ||
310 | write_lock(&ls->ls_dirtbl[bucket].lock); | 310 | spin_lock(&ls->ls_dirtbl[bucket].lock); |
311 | de = search_bucket(ls, name, namelen, bucket); | 311 | de = search_bucket(ls, name, namelen, bucket); |
312 | if (de) { | 312 | if (de) { |
313 | *r_nodeid = de->master_nodeid; | 313 | *r_nodeid = de->master_nodeid; |
314 | write_unlock(&ls->ls_dirtbl[bucket].lock); | 314 | spin_unlock(&ls->ls_dirtbl[bucket].lock); |
315 | if (*r_nodeid == nodeid) | 315 | if (*r_nodeid == nodeid) |
316 | return -EEXIST; | 316 | return -EEXIST; |
317 | return 0; | 317 | return 0; |
318 | } | 318 | } |
319 | 319 | ||
320 | write_unlock(&ls->ls_dirtbl[bucket].lock); | 320 | spin_unlock(&ls->ls_dirtbl[bucket].lock); |
321 | 321 | ||
322 | if (namelen > DLM_RESNAME_MAXLEN) | 322 | if (namelen > DLM_RESNAME_MAXLEN) |
323 | return -EINVAL; | 323 | return -EINVAL; |
@@ -330,7 +330,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name, | |||
330 | de->length = namelen; | 330 | de->length = namelen; |
331 | memcpy(de->name, name, namelen); | 331 | memcpy(de->name, name, namelen); |
332 | 332 | ||
333 | write_lock(&ls->ls_dirtbl[bucket].lock); | 333 | spin_lock(&ls->ls_dirtbl[bucket].lock); |
334 | tmp = search_bucket(ls, name, namelen, bucket); | 334 | tmp = search_bucket(ls, name, namelen, bucket); |
335 | if (tmp) { | 335 | if (tmp) { |
336 | kfree(de); | 336 | kfree(de); |
@@ -339,7 +339,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name, | |||
339 | list_add_tail(&de->list, &ls->ls_dirtbl[bucket].list); | 339 | list_add_tail(&de->list, &ls->ls_dirtbl[bucket].list); |
340 | } | 340 | } |
341 | *r_nodeid = de->master_nodeid; | 341 | *r_nodeid = de->master_nodeid; |
342 | write_unlock(&ls->ls_dirtbl[bucket].lock); | 342 | spin_unlock(&ls->ls_dirtbl[bucket].lock); |
343 | return 0; | 343 | return 0; |
344 | } | 344 | } |
345 | 345 | ||
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h index 076e86f38bc8..d01ca0a711db 100644 --- a/fs/dlm/dlm_internal.h +++ b/fs/dlm/dlm_internal.h | |||
@@ -99,7 +99,7 @@ struct dlm_direntry { | |||
99 | 99 | ||
100 | struct dlm_dirtable { | 100 | struct dlm_dirtable { |
101 | struct list_head list; | 101 | struct list_head list; |
102 | rwlock_t lock; | 102 | spinlock_t lock; |
103 | }; | 103 | }; |
104 | 104 | ||
105 | struct dlm_rsbtable { | 105 | struct dlm_rsbtable { |
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index 01e7d39c5fba..205ec95b347e 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
@@ -835,7 +835,7 @@ static int add_to_waiters(struct dlm_lkb *lkb, int mstype) | |||
835 | lkb->lkb_wait_count++; | 835 | lkb->lkb_wait_count++; |
836 | hold_lkb(lkb); | 836 | hold_lkb(lkb); |
837 | 837 | ||
838 | log_debug(ls, "add overlap %x cur %d new %d count %d flags %x", | 838 | log_debug(ls, "addwait %x cur %d overlap %d count %d f %x", |
839 | lkb->lkb_id, lkb->lkb_wait_type, mstype, | 839 | lkb->lkb_id, lkb->lkb_wait_type, mstype, |
840 | lkb->lkb_wait_count, lkb->lkb_flags); | 840 | lkb->lkb_wait_count, lkb->lkb_flags); |
841 | goto out; | 841 | goto out; |
@@ -851,7 +851,7 @@ static int add_to_waiters(struct dlm_lkb *lkb, int mstype) | |||
851 | list_add(&lkb->lkb_wait_reply, &ls->ls_waiters); | 851 | list_add(&lkb->lkb_wait_reply, &ls->ls_waiters); |
852 | out: | 852 | out: |
853 | if (error) | 853 | if (error) |
854 | log_error(ls, "add_to_waiters %x error %d flags %x %d %d %s", | 854 | log_error(ls, "addwait error %x %d flags %x %d %d %s", |
855 | lkb->lkb_id, error, lkb->lkb_flags, mstype, | 855 | lkb->lkb_id, error, lkb->lkb_flags, mstype, |
856 | lkb->lkb_wait_type, lkb->lkb_resource->res_name); | 856 | lkb->lkb_wait_type, lkb->lkb_resource->res_name); |
857 | mutex_unlock(&ls->ls_waiters_mutex); | 857 | mutex_unlock(&ls->ls_waiters_mutex); |
@@ -863,23 +863,55 @@ static int add_to_waiters(struct dlm_lkb *lkb, int mstype) | |||
863 | request reply on the requestqueue) between dlm_recover_waiters_pre() which | 863 | request reply on the requestqueue) between dlm_recover_waiters_pre() which |
864 | set RESEND and dlm_recover_waiters_post() */ | 864 | set RESEND and dlm_recover_waiters_post() */ |
865 | 865 | ||
866 | static int _remove_from_waiters(struct dlm_lkb *lkb, int mstype) | 866 | static int _remove_from_waiters(struct dlm_lkb *lkb, int mstype, |
867 | struct dlm_message *ms) | ||
867 | { | 868 | { |
868 | struct dlm_ls *ls = lkb->lkb_resource->res_ls; | 869 | struct dlm_ls *ls = lkb->lkb_resource->res_ls; |
869 | int overlap_done = 0; | 870 | int overlap_done = 0; |
870 | 871 | ||
871 | if (is_overlap_unlock(lkb) && (mstype == DLM_MSG_UNLOCK_REPLY)) { | 872 | if (is_overlap_unlock(lkb) && (mstype == DLM_MSG_UNLOCK_REPLY)) { |
873 | log_debug(ls, "remwait %x unlock_reply overlap", lkb->lkb_id); | ||
872 | lkb->lkb_flags &= ~DLM_IFL_OVERLAP_UNLOCK; | 874 | lkb->lkb_flags &= ~DLM_IFL_OVERLAP_UNLOCK; |
873 | overlap_done = 1; | 875 | overlap_done = 1; |
874 | goto out_del; | 876 | goto out_del; |
875 | } | 877 | } |
876 | 878 | ||
877 | if (is_overlap_cancel(lkb) && (mstype == DLM_MSG_CANCEL_REPLY)) { | 879 | if (is_overlap_cancel(lkb) && (mstype == DLM_MSG_CANCEL_REPLY)) { |
880 | log_debug(ls, "remwait %x cancel_reply overlap", lkb->lkb_id); | ||
878 | lkb->lkb_flags &= ~DLM_IFL_OVERLAP_CANCEL; | 881 | lkb->lkb_flags &= ~DLM_IFL_OVERLAP_CANCEL; |
879 | overlap_done = 1; | 882 | overlap_done = 1; |
880 | goto out_del; | 883 | goto out_del; |
881 | } | 884 | } |
882 | 885 | ||
886 | /* Cancel state was preemptively cleared by a successful convert, | ||
887 | see next comment, nothing to do. */ | ||
888 | |||
889 | if ((mstype == DLM_MSG_CANCEL_REPLY) && | ||
890 | (lkb->lkb_wait_type != DLM_MSG_CANCEL)) { | ||
891 | log_debug(ls, "remwait %x cancel_reply wait_type %d", | ||
892 | lkb->lkb_id, lkb->lkb_wait_type); | ||
893 | return -1; | ||
894 | } | ||
895 | |||
896 | /* Remove for the convert reply, and premptively remove for the | ||
897 | cancel reply. A convert has been granted while there's still | ||
898 | an outstanding cancel on it (the cancel is moot and the result | ||
899 | in the cancel reply should be 0). We preempt the cancel reply | ||
900 | because the app gets the convert result and then can follow up | ||
901 | with another op, like convert. This subsequent op would see the | ||
902 | lingering state of the cancel and fail with -EBUSY. */ | ||
903 | |||
904 | if ((mstype == DLM_MSG_CONVERT_REPLY) && | ||
905 | (lkb->lkb_wait_type == DLM_MSG_CONVERT) && | ||
906 | is_overlap_cancel(lkb) && ms && !ms->m_result) { | ||
907 | log_debug(ls, "remwait %x convert_reply zap overlap_cancel", | ||
908 | lkb->lkb_id); | ||
909 | lkb->lkb_wait_type = 0; | ||
910 | lkb->lkb_flags &= ~DLM_IFL_OVERLAP_CANCEL; | ||
911 | lkb->lkb_wait_count--; | ||
912 | goto out_del; | ||
913 | } | ||
914 | |||
883 | /* N.B. type of reply may not always correspond to type of original | 915 | /* N.B. type of reply may not always correspond to type of original |
884 | msg due to lookup->request optimization, verify others? */ | 916 | msg due to lookup->request optimization, verify others? */ |
885 | 917 | ||
@@ -888,8 +920,8 @@ static int _remove_from_waiters(struct dlm_lkb *lkb, int mstype) | |||
888 | goto out_del; | 920 | goto out_del; |
889 | } | 921 | } |
890 | 922 | ||
891 | log_error(ls, "remove_from_waiters lkid %x flags %x types %d %d", | 923 | log_error(ls, "remwait error %x reply %d flags %x no wait_type", |
892 | lkb->lkb_id, lkb->lkb_flags, mstype, lkb->lkb_wait_type); | 924 | lkb->lkb_id, mstype, lkb->lkb_flags); |
893 | return -1; | 925 | return -1; |
894 | 926 | ||
895 | out_del: | 927 | out_del: |
@@ -899,7 +931,7 @@ static int _remove_from_waiters(struct dlm_lkb *lkb, int mstype) | |||
899 | this would happen */ | 931 | this would happen */ |
900 | 932 | ||
901 | if (overlap_done && lkb->lkb_wait_type) { | 933 | if (overlap_done && lkb->lkb_wait_type) { |
902 | log_error(ls, "remove_from_waiters %x reply %d give up on %d", | 934 | log_error(ls, "remwait error %x reply %d wait_type %d overlap", |
903 | lkb->lkb_id, mstype, lkb->lkb_wait_type); | 935 | lkb->lkb_id, mstype, lkb->lkb_wait_type); |
904 | lkb->lkb_wait_count--; | 936 | lkb->lkb_wait_count--; |
905 | lkb->lkb_wait_type = 0; | 937 | lkb->lkb_wait_type = 0; |
@@ -921,7 +953,7 @@ static int remove_from_waiters(struct dlm_lkb *lkb, int mstype) | |||
921 | int error; | 953 | int error; |
922 | 954 | ||
923 | mutex_lock(&ls->ls_waiters_mutex); | 955 | mutex_lock(&ls->ls_waiters_mutex); |
924 | error = _remove_from_waiters(lkb, mstype); | 956 | error = _remove_from_waiters(lkb, mstype, NULL); |
925 | mutex_unlock(&ls->ls_waiters_mutex); | 957 | mutex_unlock(&ls->ls_waiters_mutex); |
926 | return error; | 958 | return error; |
927 | } | 959 | } |
@@ -936,7 +968,7 @@ static int remove_from_waiters_ms(struct dlm_lkb *lkb, struct dlm_message *ms) | |||
936 | 968 | ||
937 | if (ms != &ls->ls_stub_ms) | 969 | if (ms != &ls->ls_stub_ms) |
938 | mutex_lock(&ls->ls_waiters_mutex); | 970 | mutex_lock(&ls->ls_waiters_mutex); |
939 | error = _remove_from_waiters(lkb, ms->m_type); | 971 | error = _remove_from_waiters(lkb, ms->m_type, ms); |
940 | if (ms != &ls->ls_stub_ms) | 972 | if (ms != &ls->ls_stub_ms) |
941 | mutex_unlock(&ls->ls_waiters_mutex); | 973 | mutex_unlock(&ls->ls_waiters_mutex); |
942 | return error; | 974 | return error; |
@@ -2083,6 +2115,11 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | |||
2083 | lkb->lkb_timeout_cs = args->timeout; | 2115 | lkb->lkb_timeout_cs = args->timeout; |
2084 | rv = 0; | 2116 | rv = 0; |
2085 | out: | 2117 | out: |
2118 | if (rv) | ||
2119 | log_debug(ls, "validate_lock_args %d %x %x %x %d %d %s", | ||
2120 | rv, lkb->lkb_id, lkb->lkb_flags, args->flags, | ||
2121 | lkb->lkb_status, lkb->lkb_wait_type, | ||
2122 | lkb->lkb_resource->res_name); | ||
2086 | return rv; | 2123 | return rv; |
2087 | } | 2124 | } |
2088 | 2125 | ||
@@ -2149,6 +2186,13 @@ static int validate_unlock_args(struct dlm_lkb *lkb, struct dlm_args *args) | |||
2149 | goto out; | 2186 | goto out; |
2150 | } | 2187 | } |
2151 | 2188 | ||
2189 | /* there's nothing to cancel */ | ||
2190 | if (lkb->lkb_status == DLM_LKSTS_GRANTED && | ||
2191 | !lkb->lkb_wait_type) { | ||
2192 | rv = -EBUSY; | ||
2193 | goto out; | ||
2194 | } | ||
2195 | |||
2152 | switch (lkb->lkb_wait_type) { | 2196 | switch (lkb->lkb_wait_type) { |
2153 | case DLM_MSG_LOOKUP: | 2197 | case DLM_MSG_LOOKUP: |
2154 | case DLM_MSG_REQUEST: | 2198 | case DLM_MSG_REQUEST: |
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index aa32e5f02493..cd8e2df3c295 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c | |||
@@ -487,7 +487,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace, | |||
487 | goto out_lkbfree; | 487 | goto out_lkbfree; |
488 | for (i = 0; i < size; i++) { | 488 | for (i = 0; i < size; i++) { |
489 | INIT_LIST_HEAD(&ls->ls_dirtbl[i].list); | 489 | INIT_LIST_HEAD(&ls->ls_dirtbl[i].list); |
490 | rwlock_init(&ls->ls_dirtbl[i].lock); | 490 | spin_lock_init(&ls->ls_dirtbl[i].lock); |
491 | } | 491 | } |
492 | 492 | ||
493 | INIT_LIST_HEAD(&ls->ls_waiters); | 493 | INIT_LIST_HEAD(&ls->ls_waiters); |
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index 103a5ebd1371..609108a83267 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c | |||
@@ -2,7 +2,7 @@ | |||
2 | ******************************************************************************* | 2 | ******************************************************************************* |
3 | ** | 3 | ** |
4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | 4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
5 | ** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. | 5 | ** Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. |
6 | ** | 6 | ** |
7 | ** This copyrighted material is made available to anyone wishing to use, | 7 | ** This copyrighted material is made available to anyone wishing to use, |
8 | ** modify, copy, or redistribute it subject to the terms and conditions | 8 | ** modify, copy, or redistribute it subject to the terms and conditions |
@@ -21,7 +21,7 @@ | |||
21 | * | 21 | * |
22 | * Cluster nodes are referred to by their nodeids. nodeids are | 22 | * Cluster nodes are referred to by their nodeids. nodeids are |
23 | * simply 32 bit numbers to the locking module - if they need to | 23 | * simply 32 bit numbers to the locking module - if they need to |
24 | * be expanded for the cluster infrastructure then that is it's | 24 | * be expanded for the cluster infrastructure then that is its |
25 | * responsibility. It is this layer's | 25 | * responsibility. It is this layer's |
26 | * responsibility to resolve these into IP address or | 26 | * responsibility to resolve these into IP address or |
27 | * whatever it needs for inter-node communication. | 27 | * whatever it needs for inter-node communication. |
@@ -36,9 +36,9 @@ | |||
36 | * of high load. Also, this way, the sending thread can collect together | 36 | * of high load. Also, this way, the sending thread can collect together |
37 | * messages bound for one node and send them in one block. | 37 | * messages bound for one node and send them in one block. |
38 | * | 38 | * |
39 | * lowcomms will choose to use wither TCP or SCTP as its transport layer | 39 | * lowcomms will choose to use either TCP or SCTP as its transport layer |
40 | * depending on the configuration variable 'protocol'. This should be set | 40 | * depending on the configuration variable 'protocol'. This should be set |
41 | * to 0 (default) for TCP or 1 for SCTP. It shouldbe configured using a | 41 | * to 0 (default) for TCP or 1 for SCTP. It should be configured using a |
42 | * cluster-wide mechanism as it must be the same on all nodes of the cluster | 42 | * cluster-wide mechanism as it must be the same on all nodes of the cluster |
43 | * for the DLM to function. | 43 | * for the DLM to function. |
44 | * | 44 | * |
@@ -48,11 +48,11 @@ | |||
48 | #include <net/sock.h> | 48 | #include <net/sock.h> |
49 | #include <net/tcp.h> | 49 | #include <net/tcp.h> |
50 | #include <linux/pagemap.h> | 50 | #include <linux/pagemap.h> |
51 | #include <linux/idr.h> | ||
52 | #include <linux/file.h> | 51 | #include <linux/file.h> |
53 | #include <linux/mutex.h> | 52 | #include <linux/mutex.h> |
54 | #include <linux/sctp.h> | 53 | #include <linux/sctp.h> |
55 | #include <net/sctp/user.h> | 54 | #include <net/sctp/user.h> |
55 | #include <net/ipv6.h> | ||
56 | 56 | ||
57 | #include "dlm_internal.h" | 57 | #include "dlm_internal.h" |
58 | #include "lowcomms.h" | 58 | #include "lowcomms.h" |
@@ -60,6 +60,7 @@ | |||
60 | #include "config.h" | 60 | #include "config.h" |
61 | 61 | ||
62 | #define NEEDED_RMEM (4*1024*1024) | 62 | #define NEEDED_RMEM (4*1024*1024) |
63 | #define CONN_HASH_SIZE 32 | ||
63 | 64 | ||
64 | struct cbuf { | 65 | struct cbuf { |
65 | unsigned int base; | 66 | unsigned int base; |
@@ -114,6 +115,7 @@ struct connection { | |||
114 | int retries; | 115 | int retries; |
115 | #define MAX_CONNECT_RETRIES 3 | 116 | #define MAX_CONNECT_RETRIES 3 |
116 | int sctp_assoc; | 117 | int sctp_assoc; |
118 | struct hlist_node list; | ||
117 | struct connection *othercon; | 119 | struct connection *othercon; |
118 | struct work_struct rwork; /* Receive workqueue */ | 120 | struct work_struct rwork; /* Receive workqueue */ |
119 | struct work_struct swork; /* Send workqueue */ | 121 | struct work_struct swork; /* Send workqueue */ |
@@ -138,14 +140,37 @@ static int dlm_local_count; | |||
138 | static struct workqueue_struct *recv_workqueue; | 140 | static struct workqueue_struct *recv_workqueue; |
139 | static struct workqueue_struct *send_workqueue; | 141 | static struct workqueue_struct *send_workqueue; |
140 | 142 | ||
141 | static DEFINE_IDR(connections_idr); | 143 | static struct hlist_head connection_hash[CONN_HASH_SIZE]; |
142 | static DEFINE_MUTEX(connections_lock); | 144 | static DEFINE_MUTEX(connections_lock); |
143 | static int max_nodeid; | ||
144 | static struct kmem_cache *con_cache; | 145 | static struct kmem_cache *con_cache; |
145 | 146 | ||
146 | static void process_recv_sockets(struct work_struct *work); | 147 | static void process_recv_sockets(struct work_struct *work); |
147 | static void process_send_sockets(struct work_struct *work); | 148 | static void process_send_sockets(struct work_struct *work); |
148 | 149 | ||
150 | |||
151 | /* This is deliberately very simple because most clusters have simple | ||
152 | sequential nodeids, so we should be able to go straight to a connection | ||
153 | struct in the array */ | ||
154 | static inline int nodeid_hash(int nodeid) | ||
155 | { | ||
156 | return nodeid & (CONN_HASH_SIZE-1); | ||
157 | } | ||
158 | |||
159 | static struct connection *__find_con(int nodeid) | ||
160 | { | ||
161 | int r; | ||
162 | struct hlist_node *h; | ||
163 | struct connection *con; | ||
164 | |||
165 | r = nodeid_hash(nodeid); | ||
166 | |||
167 | hlist_for_each_entry(con, h, &connection_hash[r], list) { | ||
168 | if (con->nodeid == nodeid) | ||
169 | return con; | ||
170 | } | ||
171 | return NULL; | ||
172 | } | ||
173 | |||
149 | /* | 174 | /* |
150 | * If 'allocation' is zero then we don't attempt to create a new | 175 | * If 'allocation' is zero then we don't attempt to create a new |
151 | * connection structure for this node. | 176 | * connection structure for this node. |
@@ -154,31 +179,17 @@ static struct connection *__nodeid2con(int nodeid, gfp_t alloc) | |||
154 | { | 179 | { |
155 | struct connection *con = NULL; | 180 | struct connection *con = NULL; |
156 | int r; | 181 | int r; |
157 | int n; | ||
158 | 182 | ||
159 | con = idr_find(&connections_idr, nodeid); | 183 | con = __find_con(nodeid); |
160 | if (con || !alloc) | 184 | if (con || !alloc) |
161 | return con; | 185 | return con; |
162 | 186 | ||
163 | r = idr_pre_get(&connections_idr, alloc); | ||
164 | if (!r) | ||
165 | return NULL; | ||
166 | |||
167 | con = kmem_cache_zalloc(con_cache, alloc); | 187 | con = kmem_cache_zalloc(con_cache, alloc); |
168 | if (!con) | 188 | if (!con) |
169 | return NULL; | 189 | return NULL; |
170 | 190 | ||
171 | r = idr_get_new_above(&connections_idr, con, nodeid, &n); | 191 | r = nodeid_hash(nodeid); |
172 | if (r) { | 192 | hlist_add_head(&con->list, &connection_hash[r]); |
173 | kmem_cache_free(con_cache, con); | ||
174 | return NULL; | ||
175 | } | ||
176 | |||
177 | if (n != nodeid) { | ||
178 | idr_remove(&connections_idr, n); | ||
179 | kmem_cache_free(con_cache, con); | ||
180 | return NULL; | ||
181 | } | ||
182 | 193 | ||
183 | con->nodeid = nodeid; | 194 | con->nodeid = nodeid; |
184 | mutex_init(&con->sock_mutex); | 195 | mutex_init(&con->sock_mutex); |
@@ -189,19 +200,30 @@ static struct connection *__nodeid2con(int nodeid, gfp_t alloc) | |||
189 | 200 | ||
190 | /* Setup action pointers for child sockets */ | 201 | /* Setup action pointers for child sockets */ |
191 | if (con->nodeid) { | 202 | if (con->nodeid) { |
192 | struct connection *zerocon = idr_find(&connections_idr, 0); | 203 | struct connection *zerocon = __find_con(0); |
193 | 204 | ||
194 | con->connect_action = zerocon->connect_action; | 205 | con->connect_action = zerocon->connect_action; |
195 | if (!con->rx_action) | 206 | if (!con->rx_action) |
196 | con->rx_action = zerocon->rx_action; | 207 | con->rx_action = zerocon->rx_action; |
197 | } | 208 | } |
198 | 209 | ||
199 | if (nodeid > max_nodeid) | ||
200 | max_nodeid = nodeid; | ||
201 | |||
202 | return con; | 210 | return con; |
203 | } | 211 | } |
204 | 212 | ||
213 | /* Loop round all connections */ | ||
214 | static void foreach_conn(void (*conn_func)(struct connection *c)) | ||
215 | { | ||
216 | int i; | ||
217 | struct hlist_node *h, *n; | ||
218 | struct connection *con; | ||
219 | |||
220 | for (i = 0; i < CONN_HASH_SIZE; i++) { | ||
221 | hlist_for_each_entry_safe(con, h, n, &connection_hash[i], list){ | ||
222 | conn_func(con); | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
205 | static struct connection *nodeid2con(int nodeid, gfp_t allocation) | 227 | static struct connection *nodeid2con(int nodeid, gfp_t allocation) |
206 | { | 228 | { |
207 | struct connection *con; | 229 | struct connection *con; |
@@ -217,14 +239,17 @@ static struct connection *nodeid2con(int nodeid, gfp_t allocation) | |||
217 | static struct connection *assoc2con(int assoc_id) | 239 | static struct connection *assoc2con(int assoc_id) |
218 | { | 240 | { |
219 | int i; | 241 | int i; |
242 | struct hlist_node *h; | ||
220 | struct connection *con; | 243 | struct connection *con; |
221 | 244 | ||
222 | mutex_lock(&connections_lock); | 245 | mutex_lock(&connections_lock); |
223 | for (i=0; i<=max_nodeid; i++) { | 246 | |
224 | con = __nodeid2con(i, 0); | 247 | for (i = 0 ; i < CONN_HASH_SIZE; i++) { |
225 | if (con && con->sctp_assoc == assoc_id) { | 248 | hlist_for_each_entry(con, h, &connection_hash[i], list) { |
226 | mutex_unlock(&connections_lock); | 249 | if (con && con->sctp_assoc == assoc_id) { |
227 | return con; | 250 | mutex_unlock(&connections_lock); |
251 | return con; | ||
252 | } | ||
228 | } | 253 | } |
229 | } | 254 | } |
230 | mutex_unlock(&connections_lock); | 255 | mutex_unlock(&connections_lock); |
@@ -250,8 +275,7 @@ static int nodeid_to_addr(int nodeid, struct sockaddr *retaddr) | |||
250 | } else { | 275 | } else { |
251 | struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &addr; | 276 | struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &addr; |
252 | struct sockaddr_in6 *ret6 = (struct sockaddr_in6 *) retaddr; | 277 | struct sockaddr_in6 *ret6 = (struct sockaddr_in6 *) retaddr; |
253 | memcpy(&ret6->sin6_addr, &in6->sin6_addr, | 278 | ipv6_addr_copy(&ret6->sin6_addr, &in6->sin6_addr); |
254 | sizeof(in6->sin6_addr)); | ||
255 | } | 279 | } |
256 | 280 | ||
257 | return 0; | 281 | return 0; |
@@ -376,25 +400,23 @@ static void sctp_send_shutdown(sctp_assoc_t associd) | |||
376 | log_print("send EOF to node failed: %d", ret); | 400 | log_print("send EOF to node failed: %d", ret); |
377 | } | 401 | } |
378 | 402 | ||
403 | static void sctp_init_failed_foreach(struct connection *con) | ||
404 | { | ||
405 | con->sctp_assoc = 0; | ||
406 | if (test_and_clear_bit(CF_CONNECT_PENDING, &con->flags)) { | ||
407 | if (!test_and_set_bit(CF_WRITE_PENDING, &con->flags)) | ||
408 | queue_work(send_workqueue, &con->swork); | ||
409 | } | ||
410 | } | ||
411 | |||
379 | /* INIT failed but we don't know which node... | 412 | /* INIT failed but we don't know which node... |
380 | restart INIT on all pending nodes */ | 413 | restart INIT on all pending nodes */ |
381 | static void sctp_init_failed(void) | 414 | static void sctp_init_failed(void) |
382 | { | 415 | { |
383 | int i; | ||
384 | struct connection *con; | ||
385 | |||
386 | mutex_lock(&connections_lock); | 416 | mutex_lock(&connections_lock); |
387 | for (i=1; i<=max_nodeid; i++) { | 417 | |
388 | con = __nodeid2con(i, 0); | 418 | foreach_conn(sctp_init_failed_foreach); |
389 | if (!con) | 419 | |
390 | continue; | ||
391 | con->sctp_assoc = 0; | ||
392 | if (test_and_clear_bit(CF_CONNECT_PENDING, &con->flags)) { | ||
393 | if (!test_and_set_bit(CF_WRITE_PENDING, &con->flags)) { | ||
394 | queue_work(send_workqueue, &con->swork); | ||
395 | } | ||
396 | } | ||
397 | } | ||
398 | mutex_unlock(&connections_lock); | 420 | mutex_unlock(&connections_lock); |
399 | } | 421 | } |
400 | 422 | ||
@@ -1313,13 +1335,10 @@ out_connect: | |||
1313 | 1335 | ||
1314 | static void clean_one_writequeue(struct connection *con) | 1336 | static void clean_one_writequeue(struct connection *con) |
1315 | { | 1337 | { |
1316 | struct list_head *list; | 1338 | struct writequeue_entry *e, *safe; |
1317 | struct list_head *temp; | ||
1318 | 1339 | ||
1319 | spin_lock(&con->writequeue_lock); | 1340 | spin_lock(&con->writequeue_lock); |
1320 | list_for_each_safe(list, temp, &con->writequeue) { | 1341 | list_for_each_entry_safe(e, safe, &con->writequeue, list) { |
1321 | struct writequeue_entry *e = | ||
1322 | list_entry(list, struct writequeue_entry, list); | ||
1323 | list_del(&e->list); | 1342 | list_del(&e->list); |
1324 | free_entry(e); | 1343 | free_entry(e); |
1325 | } | 1344 | } |
@@ -1369,14 +1388,7 @@ static void process_send_sockets(struct work_struct *work) | |||
1369 | /* Discard all entries on the write queues */ | 1388 | /* Discard all entries on the write queues */ |
1370 | static void clean_writequeues(void) | 1389 | static void clean_writequeues(void) |
1371 | { | 1390 | { |
1372 | int nodeid; | 1391 | foreach_conn(clean_one_writequeue); |
1373 | |||
1374 | for (nodeid = 1; nodeid <= max_nodeid; nodeid++) { | ||
1375 | struct connection *con = __nodeid2con(nodeid, 0); | ||
1376 | |||
1377 | if (con) | ||
1378 | clean_one_writequeue(con); | ||
1379 | } | ||
1380 | } | 1392 | } |
1381 | 1393 | ||
1382 | static void work_stop(void) | 1394 | static void work_stop(void) |
@@ -1406,23 +1418,29 @@ static int work_start(void) | |||
1406 | return 0; | 1418 | return 0; |
1407 | } | 1419 | } |
1408 | 1420 | ||
1409 | void dlm_lowcomms_stop(void) | 1421 | static void stop_conn(struct connection *con) |
1410 | { | 1422 | { |
1411 | int i; | 1423 | con->flags |= 0x0F; |
1412 | struct connection *con; | 1424 | if (con->sock) |
1425 | con->sock->sk->sk_user_data = NULL; | ||
1426 | } | ||
1413 | 1427 | ||
1428 | static void free_conn(struct connection *con) | ||
1429 | { | ||
1430 | close_connection(con, true); | ||
1431 | if (con->othercon) | ||
1432 | kmem_cache_free(con_cache, con->othercon); | ||
1433 | hlist_del(&con->list); | ||
1434 | kmem_cache_free(con_cache, con); | ||
1435 | } | ||
1436 | |||
1437 | void dlm_lowcomms_stop(void) | ||
1438 | { | ||
1414 | /* Set all the flags to prevent any | 1439 | /* Set all the flags to prevent any |
1415 | socket activity. | 1440 | socket activity. |
1416 | */ | 1441 | */ |
1417 | mutex_lock(&connections_lock); | 1442 | mutex_lock(&connections_lock); |
1418 | for (i = 0; i <= max_nodeid; i++) { | 1443 | foreach_conn(stop_conn); |
1419 | con = __nodeid2con(i, 0); | ||
1420 | if (con) { | ||
1421 | con->flags |= 0x0F; | ||
1422 | if (con->sock) | ||
1423 | con->sock->sk->sk_user_data = NULL; | ||
1424 | } | ||
1425 | } | ||
1426 | mutex_unlock(&connections_lock); | 1444 | mutex_unlock(&connections_lock); |
1427 | 1445 | ||
1428 | work_stop(); | 1446 | work_stop(); |
@@ -1430,25 +1448,20 @@ void dlm_lowcomms_stop(void) | |||
1430 | mutex_lock(&connections_lock); | 1448 | mutex_lock(&connections_lock); |
1431 | clean_writequeues(); | 1449 | clean_writequeues(); |
1432 | 1450 | ||
1433 | for (i = 0; i <= max_nodeid; i++) { | 1451 | foreach_conn(free_conn); |
1434 | con = __nodeid2con(i, 0); | 1452 | |
1435 | if (con) { | ||
1436 | close_connection(con, true); | ||
1437 | if (con->othercon) | ||
1438 | kmem_cache_free(con_cache, con->othercon); | ||
1439 | kmem_cache_free(con_cache, con); | ||
1440 | } | ||
1441 | } | ||
1442 | max_nodeid = 0; | ||
1443 | mutex_unlock(&connections_lock); | 1453 | mutex_unlock(&connections_lock); |
1444 | kmem_cache_destroy(con_cache); | 1454 | kmem_cache_destroy(con_cache); |
1445 | idr_init(&connections_idr); | ||
1446 | } | 1455 | } |
1447 | 1456 | ||
1448 | int dlm_lowcomms_start(void) | 1457 | int dlm_lowcomms_start(void) |
1449 | { | 1458 | { |
1450 | int error = -EINVAL; | 1459 | int error = -EINVAL; |
1451 | struct connection *con; | 1460 | struct connection *con; |
1461 | int i; | ||
1462 | |||
1463 | for (i = 0; i < CONN_HASH_SIZE; i++) | ||
1464 | INIT_HLIST_HEAD(&connection_hash[i]); | ||
1452 | 1465 | ||
1453 | init_local(); | 1466 | init_local(); |
1454 | if (!dlm_local_count) { | 1467 | if (!dlm_local_count) { |
diff --git a/fs/dlm/user.c b/fs/dlm/user.c index 065149e84f42..ebce994ab0b7 100644 --- a/fs/dlm/user.c +++ b/fs/dlm/user.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2006-2008 Red Hat, Inc. All rights reserved. | 2 | * Copyright (C) 2006-2009 Red Hat, Inc. All rights reserved. |
3 | * | 3 | * |
4 | * This copyrighted material is made available to anyone wishing to use, | 4 | * This copyrighted material is made available to anyone wishing to use, |
5 | * modify, copy, or redistribute it subject to the terms and conditions | 5 | * modify, copy, or redistribute it subject to the terms and conditions |
@@ -84,7 +84,7 @@ struct dlm_lock_result32 { | |||
84 | 84 | ||
85 | static void compat_input(struct dlm_write_request *kb, | 85 | static void compat_input(struct dlm_write_request *kb, |
86 | struct dlm_write_request32 *kb32, | 86 | struct dlm_write_request32 *kb32, |
87 | size_t count) | 87 | int namelen) |
88 | { | 88 | { |
89 | kb->version[0] = kb32->version[0]; | 89 | kb->version[0] = kb32->version[0]; |
90 | kb->version[1] = kb32->version[1]; | 90 | kb->version[1] = kb32->version[1]; |
@@ -96,8 +96,7 @@ static void compat_input(struct dlm_write_request *kb, | |||
96 | kb->cmd == DLM_USER_REMOVE_LOCKSPACE) { | 96 | kb->cmd == DLM_USER_REMOVE_LOCKSPACE) { |
97 | kb->i.lspace.flags = kb32->i.lspace.flags; | 97 | kb->i.lspace.flags = kb32->i.lspace.flags; |
98 | kb->i.lspace.minor = kb32->i.lspace.minor; | 98 | kb->i.lspace.minor = kb32->i.lspace.minor; |
99 | memcpy(kb->i.lspace.name, kb32->i.lspace.name, count - | 99 | memcpy(kb->i.lspace.name, kb32->i.lspace.name, namelen); |
100 | offsetof(struct dlm_write_request32, i.lspace.name)); | ||
101 | } else if (kb->cmd == DLM_USER_PURGE) { | 100 | } else if (kb->cmd == DLM_USER_PURGE) { |
102 | kb->i.purge.nodeid = kb32->i.purge.nodeid; | 101 | kb->i.purge.nodeid = kb32->i.purge.nodeid; |
103 | kb->i.purge.pid = kb32->i.purge.pid; | 102 | kb->i.purge.pid = kb32->i.purge.pid; |
@@ -115,8 +114,7 @@ static void compat_input(struct dlm_write_request *kb, | |||
115 | kb->i.lock.bastaddr = (void *)(long)kb32->i.lock.bastaddr; | 114 | kb->i.lock.bastaddr = (void *)(long)kb32->i.lock.bastaddr; |
116 | kb->i.lock.lksb = (void *)(long)kb32->i.lock.lksb; | 115 | kb->i.lock.lksb = (void *)(long)kb32->i.lock.lksb; |
117 | memcpy(kb->i.lock.lvb, kb32->i.lock.lvb, DLM_USER_LVB_LEN); | 116 | memcpy(kb->i.lock.lvb, kb32->i.lock.lvb, DLM_USER_LVB_LEN); |
118 | memcpy(kb->i.lock.name, kb32->i.lock.name, count - | 117 | memcpy(kb->i.lock.name, kb32->i.lock.name, namelen); |
119 | offsetof(struct dlm_write_request32, i.lock.name)); | ||
120 | } | 118 | } |
121 | } | 119 | } |
122 | 120 | ||
@@ -539,9 +537,16 @@ static ssize_t device_write(struct file *file, const char __user *buf, | |||
539 | #ifdef CONFIG_COMPAT | 537 | #ifdef CONFIG_COMPAT |
540 | if (!kbuf->is64bit) { | 538 | if (!kbuf->is64bit) { |
541 | struct dlm_write_request32 *k32buf; | 539 | struct dlm_write_request32 *k32buf; |
540 | int namelen = 0; | ||
541 | |||
542 | if (count > sizeof(struct dlm_write_request32)) | ||
543 | namelen = count - sizeof(struct dlm_write_request32); | ||
544 | |||
542 | k32buf = (struct dlm_write_request32 *)kbuf; | 545 | k32buf = (struct dlm_write_request32 *)kbuf; |
543 | kbuf = kmalloc(count + 1 + (sizeof(struct dlm_write_request) - | 546 | |
544 | sizeof(struct dlm_write_request32)), GFP_KERNEL); | 547 | /* add 1 after namelen so that the name string is terminated */ |
548 | kbuf = kzalloc(sizeof(struct dlm_write_request) + namelen + 1, | ||
549 | GFP_KERNEL); | ||
545 | if (!kbuf) { | 550 | if (!kbuf) { |
546 | kfree(k32buf); | 551 | kfree(k32buf); |
547 | return -ENOMEM; | 552 | return -ENOMEM; |
@@ -549,7 +554,8 @@ static ssize_t device_write(struct file *file, const char __user *buf, | |||
549 | 554 | ||
550 | if (proc) | 555 | if (proc) |
551 | set_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags); | 556 | set_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags); |
552 | compat_input(kbuf, k32buf, count + 1); | 557 | |
558 | compat_input(kbuf, k32buf, namelen); | ||
553 | kfree(k32buf); | 559 | kfree(k32buf); |
554 | } | 560 | } |
555 | #endif | 561 | #endif |
diff --git a/fs/drop_caches.c b/fs/drop_caches.c index 3e5637fc3779..44d725f612cf 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c | |||
@@ -18,7 +18,7 @@ static void drop_pagecache_sb(struct super_block *sb) | |||
18 | 18 | ||
19 | spin_lock(&inode_lock); | 19 | spin_lock(&inode_lock); |
20 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 20 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
21 | if (inode->i_state & (I_FREEING|I_WILL_FREE)) | 21 | if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) |
22 | continue; | 22 | continue; |
23 | if (inode->i_mapping->nrpages == 0) | 23 | if (inode->i_mapping->nrpages == 0) |
24 | continue; | 24 | continue; |
diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c index 5e596583946c..2dda5ade75bc 100644 --- a/fs/ecryptfs/dentry.c +++ b/fs/ecryptfs/dentry.c | |||
@@ -89,7 +89,7 @@ static void ecryptfs_d_release(struct dentry *dentry) | |||
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | 91 | ||
92 | struct dentry_operations ecryptfs_dops = { | 92 | const struct dentry_operations ecryptfs_dops = { |
93 | .d_revalidate = ecryptfs_d_revalidate, | 93 | .d_revalidate = ecryptfs_d_revalidate, |
94 | .d_release = ecryptfs_d_release, | 94 | .d_release = ecryptfs_d_release, |
95 | }; | 95 | }; |
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index ac749d4d644f..064c5820e4e5 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
@@ -580,7 +580,7 @@ extern const struct inode_operations ecryptfs_main_iops; | |||
580 | extern const struct inode_operations ecryptfs_dir_iops; | 580 | extern const struct inode_operations ecryptfs_dir_iops; |
581 | extern const struct inode_operations ecryptfs_symlink_iops; | 581 | extern const struct inode_operations ecryptfs_symlink_iops; |
582 | extern const struct super_operations ecryptfs_sops; | 582 | extern const struct super_operations ecryptfs_sops; |
583 | extern struct dentry_operations ecryptfs_dops; | 583 | extern const struct dentry_operations ecryptfs_dops; |
584 | extern struct address_space_operations ecryptfs_aops; | 584 | extern struct address_space_operations ecryptfs_aops; |
585 | extern int ecryptfs_verbosity; | 585 | extern int ecryptfs_verbosity; |
586 | extern unsigned int ecryptfs_message_buf_len; | 586 | extern unsigned int ecryptfs_message_buf_len; |
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index 4a29d6376081..7f8d2e5a7ea6 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c | |||
@@ -570,7 +570,7 @@ do_more: | |||
570 | error_return: | 570 | error_return: |
571 | brelse(bitmap_bh); | 571 | brelse(bitmap_bh); |
572 | release_blocks(sb, freed); | 572 | release_blocks(sb, freed); |
573 | DQUOT_FREE_BLOCK(inode, freed); | 573 | vfs_dq_free_block(inode, freed); |
574 | } | 574 | } |
575 | 575 | ||
576 | /** | 576 | /** |
@@ -1247,7 +1247,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal, | |||
1247 | /* | 1247 | /* |
1248 | * Check quota for allocation of this block. | 1248 | * Check quota for allocation of this block. |
1249 | */ | 1249 | */ |
1250 | if (DQUOT_ALLOC_BLOCK(inode, num)) { | 1250 | if (vfs_dq_alloc_block(inode, num)) { |
1251 | *errp = -EDQUOT; | 1251 | *errp = -EDQUOT; |
1252 | return 0; | 1252 | return 0; |
1253 | } | 1253 | } |
@@ -1409,7 +1409,7 @@ allocated: | |||
1409 | 1409 | ||
1410 | *errp = 0; | 1410 | *errp = 0; |
1411 | brelse(bitmap_bh); | 1411 | brelse(bitmap_bh); |
1412 | DQUOT_FREE_BLOCK(inode, *count-num); | 1412 | vfs_dq_free_block(inode, *count-num); |
1413 | *count = num; | 1413 | *count = num; |
1414 | return ret_block; | 1414 | return ret_block; |
1415 | 1415 | ||
@@ -1420,7 +1420,7 @@ out: | |||
1420 | * Undo the block allocation | 1420 | * Undo the block allocation |
1421 | */ | 1421 | */ |
1422 | if (!performed_allocation) | 1422 | if (!performed_allocation) |
1423 | DQUOT_FREE_BLOCK(inode, *count); | 1423 | vfs_dq_free_block(inode, *count); |
1424 | brelse(bitmap_bh); | 1424 | brelse(bitmap_bh); |
1425 | return 0; | 1425 | return 0; |
1426 | } | 1426 | } |
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index 66321a877e74..15387c9c17d8 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c | |||
@@ -121,8 +121,8 @@ void ext2_free_inode (struct inode * inode) | |||
121 | if (!is_bad_inode(inode)) { | 121 | if (!is_bad_inode(inode)) { |
122 | /* Quota is already initialized in iput() */ | 122 | /* Quota is already initialized in iput() */ |
123 | ext2_xattr_delete_inode(inode); | 123 | ext2_xattr_delete_inode(inode); |
124 | DQUOT_FREE_INODE(inode); | 124 | vfs_dq_free_inode(inode); |
125 | DQUOT_DROP(inode); | 125 | vfs_dq_drop(inode); |
126 | } | 126 | } |
127 | 127 | ||
128 | es = EXT2_SB(sb)->s_es; | 128 | es = EXT2_SB(sb)->s_es; |
@@ -586,7 +586,7 @@ got: | |||
586 | goto fail_drop; | 586 | goto fail_drop; |
587 | } | 587 | } |
588 | 588 | ||
589 | if (DQUOT_ALLOC_INODE(inode)) { | 589 | if (vfs_dq_alloc_inode(inode)) { |
590 | err = -EDQUOT; | 590 | err = -EDQUOT; |
591 | goto fail_drop; | 591 | goto fail_drop; |
592 | } | 592 | } |
@@ -605,10 +605,10 @@ got: | |||
605 | return inode; | 605 | return inode; |
606 | 606 | ||
607 | fail_free_drop: | 607 | fail_free_drop: |
608 | DQUOT_FREE_INODE(inode); | 608 | vfs_dq_free_inode(inode); |
609 | 609 | ||
610 | fail_drop: | 610 | fail_drop: |
611 | DQUOT_DROP(inode); | 611 | vfs_dq_drop(inode); |
612 | inode->i_flags |= S_NOQUOTA; | 612 | inode->i_flags |= S_NOQUOTA; |
613 | inode->i_nlink = 0; | 613 | inode->i_nlink = 0; |
614 | unlock_new_inode(inode); | 614 | unlock_new_inode(inode); |
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 23fff2f87783..b43b95563663 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
@@ -1444,7 +1444,7 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr) | |||
1444 | return error; | 1444 | return error; |
1445 | if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) || | 1445 | if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) || |
1446 | (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) { | 1446 | (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) { |
1447 | error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0; | 1447 | error = vfs_dq_transfer(inode, iattr) ? -EDQUOT : 0; |
1448 | if (error) | 1448 | if (error) |
1449 | return error; | 1449 | return error; |
1450 | } | 1450 | } |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 7c6e3606f0ec..f983225266dc 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -1331,6 +1331,7 @@ static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, | |||
1331 | sb->s_blocksize - offset : toread; | 1331 | sb->s_blocksize - offset : toread; |
1332 | 1332 | ||
1333 | tmp_bh.b_state = 0; | 1333 | tmp_bh.b_state = 0; |
1334 | tmp_bh.b_size = sb->s_blocksize; | ||
1334 | err = ext2_get_block(inode, blk, &tmp_bh, 0); | 1335 | err = ext2_get_block(inode, blk, &tmp_bh, 0); |
1335 | if (err < 0) | 1336 | if (err < 0) |
1336 | return err; | 1337 | return err; |
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index 987a5261cc2e..7913531ec6d5 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c | |||
@@ -642,7 +642,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, | |||
642 | ea_bdebug(new_bh, "reusing block"); | 642 | ea_bdebug(new_bh, "reusing block"); |
643 | 643 | ||
644 | error = -EDQUOT; | 644 | error = -EDQUOT; |
645 | if (DQUOT_ALLOC_BLOCK(inode, 1)) { | 645 | if (vfs_dq_alloc_block(inode, 1)) { |
646 | unlock_buffer(new_bh); | 646 | unlock_buffer(new_bh); |
647 | goto cleanup; | 647 | goto cleanup; |
648 | } | 648 | } |
@@ -699,7 +699,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, | |||
699 | * as if nothing happened and cleanup the unused block */ | 699 | * as if nothing happened and cleanup the unused block */ |
700 | if (error && error != -ENOSPC) { | 700 | if (error && error != -ENOSPC) { |
701 | if (new_bh && new_bh != old_bh) | 701 | if (new_bh && new_bh != old_bh) |
702 | DQUOT_FREE_BLOCK(inode, 1); | 702 | vfs_dq_free_block(inode, 1); |
703 | goto cleanup; | 703 | goto cleanup; |
704 | } | 704 | } |
705 | } else | 705 | } else |
@@ -731,7 +731,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, | |||
731 | le32_add_cpu(&HDR(old_bh)->h_refcount, -1); | 731 | le32_add_cpu(&HDR(old_bh)->h_refcount, -1); |
732 | if (ce) | 732 | if (ce) |
733 | mb_cache_entry_release(ce); | 733 | mb_cache_entry_release(ce); |
734 | DQUOT_FREE_BLOCK(inode, 1); | 734 | vfs_dq_free_block(inode, 1); |
735 | mark_buffer_dirty(old_bh); | 735 | mark_buffer_dirty(old_bh); |
736 | ea_bdebug(old_bh, "refcount now=%d", | 736 | ea_bdebug(old_bh, "refcount now=%d", |
737 | le32_to_cpu(HDR(old_bh)->h_refcount)); | 737 | le32_to_cpu(HDR(old_bh)->h_refcount)); |
@@ -794,7 +794,7 @@ ext2_xattr_delete_inode(struct inode *inode) | |||
794 | mark_buffer_dirty(bh); | 794 | mark_buffer_dirty(bh); |
795 | if (IS_SYNC(inode)) | 795 | if (IS_SYNC(inode)) |
796 | sync_dirty_buffer(bh); | 796 | sync_dirty_buffer(bh); |
797 | DQUOT_FREE_BLOCK(inode, 1); | 797 | vfs_dq_free_block(inode, 1); |
798 | } | 798 | } |
799 | EXT2_I(inode)->i_file_acl = 0; | 799 | EXT2_I(inode)->i_file_acl = 0; |
800 | 800 | ||
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c index 0dbf1c048475..225202db8974 100644 --- a/fs/ext3/balloc.c +++ b/fs/ext3/balloc.c | |||
@@ -676,7 +676,7 @@ void ext3_free_blocks(handle_t *handle, struct inode *inode, | |||
676 | } | 676 | } |
677 | ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks); | 677 | ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks); |
678 | if (dquot_freed_blocks) | 678 | if (dquot_freed_blocks) |
679 | DQUOT_FREE_BLOCK(inode, dquot_freed_blocks); | 679 | vfs_dq_free_block(inode, dquot_freed_blocks); |
680 | return; | 680 | return; |
681 | } | 681 | } |
682 | 682 | ||
@@ -1502,7 +1502,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode, | |||
1502 | /* | 1502 | /* |
1503 | * Check quota for allocation of this block. | 1503 | * Check quota for allocation of this block. |
1504 | */ | 1504 | */ |
1505 | if (DQUOT_ALLOC_BLOCK(inode, num)) { | 1505 | if (vfs_dq_alloc_block(inode, num)) { |
1506 | *errp = -EDQUOT; | 1506 | *errp = -EDQUOT; |
1507 | return 0; | 1507 | return 0; |
1508 | } | 1508 | } |
@@ -1714,7 +1714,7 @@ allocated: | |||
1714 | 1714 | ||
1715 | *errp = 0; | 1715 | *errp = 0; |
1716 | brelse(bitmap_bh); | 1716 | brelse(bitmap_bh); |
1717 | DQUOT_FREE_BLOCK(inode, *count-num); | 1717 | vfs_dq_free_block(inode, *count-num); |
1718 | *count = num; | 1718 | *count = num; |
1719 | return ret_block; | 1719 | return ret_block; |
1720 | 1720 | ||
@@ -1729,7 +1729,7 @@ out: | |||
1729 | * Undo the block allocation | 1729 | * Undo the block allocation |
1730 | */ | 1730 | */ |
1731 | if (!performed_allocation) | 1731 | if (!performed_allocation) |
1732 | DQUOT_FREE_BLOCK(inode, *count); | 1732 | vfs_dq_free_block(inode, *count); |
1733 | brelse(bitmap_bh); | 1733 | brelse(bitmap_bh); |
1734 | return 0; | 1734 | return 0; |
1735 | } | 1735 | } |
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 8de6c720e510..dd13d60d524b 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c | |||
@@ -123,10 +123,10 @@ void ext3_free_inode (handle_t *handle, struct inode * inode) | |||
123 | * Note: we must free any quota before locking the superblock, | 123 | * Note: we must free any quota before locking the superblock, |
124 | * as writing the quota to disk may need the lock as well. | 124 | * as writing the quota to disk may need the lock as well. |
125 | */ | 125 | */ |
126 | DQUOT_INIT(inode); | 126 | vfs_dq_init(inode); |
127 | ext3_xattr_delete_inode(handle, inode); | 127 | ext3_xattr_delete_inode(handle, inode); |
128 | DQUOT_FREE_INODE(inode); | 128 | vfs_dq_free_inode(inode); |
129 | DQUOT_DROP(inode); | 129 | vfs_dq_drop(inode); |
130 | 130 | ||
131 | is_directory = S_ISDIR(inode->i_mode); | 131 | is_directory = S_ISDIR(inode->i_mode); |
132 | 132 | ||
@@ -589,7 +589,7 @@ got: | |||
589 | sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0; | 589 | sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0; |
590 | 590 | ||
591 | ret = inode; | 591 | ret = inode; |
592 | if(DQUOT_ALLOC_INODE(inode)) { | 592 | if (vfs_dq_alloc_inode(inode)) { |
593 | err = -EDQUOT; | 593 | err = -EDQUOT; |
594 | goto fail_drop; | 594 | goto fail_drop; |
595 | } | 595 | } |
@@ -620,10 +620,10 @@ really_out: | |||
620 | return ret; | 620 | return ret; |
621 | 621 | ||
622 | fail_free_drop: | 622 | fail_free_drop: |
623 | DQUOT_FREE_INODE(inode); | 623 | vfs_dq_free_inode(inode); |
624 | 624 | ||
625 | fail_drop: | 625 | fail_drop: |
626 | DQUOT_DROP(inode); | 626 | vfs_dq_drop(inode); |
627 | inode->i_flags |= S_NOQUOTA; | 627 | inode->i_flags |= S_NOQUOTA; |
628 | inode->i_nlink = 0; | 628 | inode->i_nlink = 0; |
629 | unlock_new_inode(inode); | 629 | unlock_new_inode(inode); |
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 05e5c2e5c0d7..4a09ff169870 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
@@ -3063,7 +3063,7 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr) | |||
3063 | error = PTR_ERR(handle); | 3063 | error = PTR_ERR(handle); |
3064 | goto err_out; | 3064 | goto err_out; |
3065 | } | 3065 | } |
3066 | error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0; | 3066 | error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0; |
3067 | if (error) { | 3067 | if (error) { |
3068 | ext3_journal_stop(handle); | 3068 | ext3_journal_stop(handle); |
3069 | return error; | 3069 | return error; |
@@ -3154,7 +3154,7 @@ static int ext3_writepage_trans_blocks(struct inode *inode) | |||
3154 | ret = 2 * (bpp + indirects) + 2; | 3154 | ret = 2 * (bpp + indirects) + 2; |
3155 | 3155 | ||
3156 | #ifdef CONFIG_QUOTA | 3156 | #ifdef CONFIG_QUOTA |
3157 | /* We know that structure was already allocated during DQUOT_INIT so | 3157 | /* We know that structure was already allocated during vfs_dq_init so |
3158 | * we will be updating only the data blocks + inodes */ | 3158 | * we will be updating only the data blocks + inodes */ |
3159 | ret += 2*EXT3_QUOTA_TRANS_BLOCKS(inode->i_sb); | 3159 | ret += 2*EXT3_QUOTA_TRANS_BLOCKS(inode->i_sb); |
3160 | #endif | 3160 | #endif |
@@ -3245,7 +3245,7 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode) | |||
3245 | * i_size has been changed by generic_commit_write() and we thus need | 3245 | * i_size has been changed by generic_commit_write() and we thus need |
3246 | * to include the updated inode in the current transaction. | 3246 | * to include the updated inode in the current transaction. |
3247 | * | 3247 | * |
3248 | * Also, DQUOT_ALLOC_SPACE() will always dirty the inode when blocks | 3248 | * Also, vfs_dq_alloc_space() will always dirty the inode when blocks |
3249 | * are allocated to the file. | 3249 | * are allocated to the file. |
3250 | * | 3250 | * |
3251 | * If the inode is marked synchronous, we don't honour that here - doing | 3251 | * If the inode is marked synchronous, we don't honour that here - doing |
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 4db4ffa1edad..e2fc63cbba8b 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -2049,7 +2049,7 @@ static int ext3_rmdir (struct inode * dir, struct dentry *dentry) | |||
2049 | 2049 | ||
2050 | /* Initialize quotas before so that eventual writes go in | 2050 | /* Initialize quotas before so that eventual writes go in |
2051 | * separate transaction */ | 2051 | * separate transaction */ |
2052 | DQUOT_INIT(dentry->d_inode); | 2052 | vfs_dq_init(dentry->d_inode); |
2053 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2053 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); |
2054 | if (IS_ERR(handle)) | 2054 | if (IS_ERR(handle)) |
2055 | return PTR_ERR(handle); | 2055 | return PTR_ERR(handle); |
@@ -2108,7 +2108,7 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry) | |||
2108 | 2108 | ||
2109 | /* Initialize quotas before so that eventual writes go | 2109 | /* Initialize quotas before so that eventual writes go |
2110 | * in separate transaction */ | 2110 | * in separate transaction */ |
2111 | DQUOT_INIT(dentry->d_inode); | 2111 | vfs_dq_init(dentry->d_inode); |
2112 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2112 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); |
2113 | if (IS_ERR(handle)) | 2113 | if (IS_ERR(handle)) |
2114 | return PTR_ERR(handle); | 2114 | return PTR_ERR(handle); |
@@ -2272,7 +2272,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, | |||
2272 | /* Initialize quotas before so that eventual writes go | 2272 | /* Initialize quotas before so that eventual writes go |
2273 | * in separate transaction */ | 2273 | * in separate transaction */ |
2274 | if (new_dentry->d_inode) | 2274 | if (new_dentry->d_inode) |
2275 | DQUOT_INIT(new_dentry->d_inode); | 2275 | vfs_dq_init(new_dentry->d_inode); |
2276 | handle = ext3_journal_start(old_dir, 2 * | 2276 | handle = ext3_journal_start(old_dir, 2 * |
2277 | EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) + | 2277 | EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) + |
2278 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2); | 2278 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2); |
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 4a970411a458..9e5b8e387e1e 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -707,8 +707,6 @@ static int bdev_try_to_free_page(struct super_block *sb, struct page *page, | |||
707 | #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group") | 707 | #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group") |
708 | #define QTYPE2MOPT(on, t) ((t)==USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) | 708 | #define QTYPE2MOPT(on, t) ((t)==USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) |
709 | 709 | ||
710 | static int ext3_dquot_initialize(struct inode *inode, int type); | ||
711 | static int ext3_dquot_drop(struct inode *inode); | ||
712 | static int ext3_write_dquot(struct dquot *dquot); | 710 | static int ext3_write_dquot(struct dquot *dquot); |
713 | static int ext3_acquire_dquot(struct dquot *dquot); | 711 | static int ext3_acquire_dquot(struct dquot *dquot); |
714 | static int ext3_release_dquot(struct dquot *dquot); | 712 | static int ext3_release_dquot(struct dquot *dquot); |
@@ -723,8 +721,8 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type, | |||
723 | const char *data, size_t len, loff_t off); | 721 | const char *data, size_t len, loff_t off); |
724 | 722 | ||
725 | static struct dquot_operations ext3_quota_operations = { | 723 | static struct dquot_operations ext3_quota_operations = { |
726 | .initialize = ext3_dquot_initialize, | 724 | .initialize = dquot_initialize, |
727 | .drop = ext3_dquot_drop, | 725 | .drop = dquot_drop, |
728 | .alloc_space = dquot_alloc_space, | 726 | .alloc_space = dquot_alloc_space, |
729 | .alloc_inode = dquot_alloc_inode, | 727 | .alloc_inode = dquot_alloc_inode, |
730 | .free_space = dquot_free_space, | 728 | .free_space = dquot_free_space, |
@@ -1438,7 +1436,7 @@ static void ext3_orphan_cleanup (struct super_block * sb, | |||
1438 | } | 1436 | } |
1439 | 1437 | ||
1440 | list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); | 1438 | list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); |
1441 | DQUOT_INIT(inode); | 1439 | vfs_dq_init(inode); |
1442 | if (inode->i_nlink) { | 1440 | if (inode->i_nlink) { |
1443 | printk(KERN_DEBUG | 1441 | printk(KERN_DEBUG |
1444 | "%s: truncating inode %lu to %Ld bytes\n", | 1442 | "%s: truncating inode %lu to %Ld bytes\n", |
@@ -2702,7 +2700,7 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf) | |||
2702 | * Process 1 Process 2 | 2700 | * Process 1 Process 2 |
2703 | * ext3_create() quota_sync() | 2701 | * ext3_create() quota_sync() |
2704 | * journal_start() write_dquot() | 2702 | * journal_start() write_dquot() |
2705 | * DQUOT_INIT() down(dqio_mutex) | 2703 | * vfs_dq_init() down(dqio_mutex) |
2706 | * down(dqio_mutex) journal_start() | 2704 | * down(dqio_mutex) journal_start() |
2707 | * | 2705 | * |
2708 | */ | 2706 | */ |
@@ -2714,44 +2712,6 @@ static inline struct inode *dquot_to_inode(struct dquot *dquot) | |||
2714 | return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type]; | 2712 | return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type]; |
2715 | } | 2713 | } |
2716 | 2714 | ||
2717 | static int ext3_dquot_initialize(struct inode *inode, int type) | ||
2718 | { | ||
2719 | handle_t *handle; | ||
2720 | int ret, err; | ||
2721 | |||
2722 | /* We may create quota structure so we need to reserve enough blocks */ | ||
2723 | handle = ext3_journal_start(inode, 2*EXT3_QUOTA_INIT_BLOCKS(inode->i_sb)); | ||
2724 | if (IS_ERR(handle)) | ||
2725 | return PTR_ERR(handle); | ||
2726 | ret = dquot_initialize(inode, type); | ||
2727 | err = ext3_journal_stop(handle); | ||
2728 | if (!ret) | ||
2729 | ret = err; | ||
2730 | return ret; | ||
2731 | } | ||
2732 | |||
2733 | static int ext3_dquot_drop(struct inode *inode) | ||
2734 | { | ||
2735 | handle_t *handle; | ||
2736 | int ret, err; | ||
2737 | |||
2738 | /* We may delete quota structure so we need to reserve enough blocks */ | ||
2739 | handle = ext3_journal_start(inode, 2*EXT3_QUOTA_DEL_BLOCKS(inode->i_sb)); | ||
2740 | if (IS_ERR(handle)) { | ||
2741 | /* | ||
2742 | * We call dquot_drop() anyway to at least release references | ||
2743 | * to quota structures so that umount does not hang. | ||
2744 | */ | ||
2745 | dquot_drop(inode); | ||
2746 | return PTR_ERR(handle); | ||
2747 | } | ||
2748 | ret = dquot_drop(inode); | ||
2749 | err = ext3_journal_stop(handle); | ||
2750 | if (!ret) | ||
2751 | ret = err; | ||
2752 | return ret; | ||
2753 | } | ||
2754 | |||
2755 | static int ext3_write_dquot(struct dquot *dquot) | 2715 | static int ext3_write_dquot(struct dquot *dquot) |
2756 | { | 2716 | { |
2757 | int ret, err; | 2717 | int ret, err; |
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c index 175414ac2210..83b7be849bd5 100644 --- a/fs/ext3/xattr.c +++ b/fs/ext3/xattr.c | |||
@@ -498,7 +498,7 @@ ext3_xattr_release_block(handle_t *handle, struct inode *inode, | |||
498 | error = ext3_journal_dirty_metadata(handle, bh); | 498 | error = ext3_journal_dirty_metadata(handle, bh); |
499 | if (IS_SYNC(inode)) | 499 | if (IS_SYNC(inode)) |
500 | handle->h_sync = 1; | 500 | handle->h_sync = 1; |
501 | DQUOT_FREE_BLOCK(inode, 1); | 501 | vfs_dq_free_block(inode, 1); |
502 | ea_bdebug(bh, "refcount now=%d; releasing", | 502 | ea_bdebug(bh, "refcount now=%d; releasing", |
503 | le32_to_cpu(BHDR(bh)->h_refcount)); | 503 | le32_to_cpu(BHDR(bh)->h_refcount)); |
504 | if (ce) | 504 | if (ce) |
@@ -774,7 +774,7 @@ inserted: | |||
774 | /* The old block is released after updating | 774 | /* The old block is released after updating |
775 | the inode. */ | 775 | the inode. */ |
776 | error = -EDQUOT; | 776 | error = -EDQUOT; |
777 | if (DQUOT_ALLOC_BLOCK(inode, 1)) | 777 | if (vfs_dq_alloc_block(inode, 1)) |
778 | goto cleanup; | 778 | goto cleanup; |
779 | error = ext3_journal_get_write_access(handle, | 779 | error = ext3_journal_get_write_access(handle, |
780 | new_bh); | 780 | new_bh); |
@@ -848,7 +848,7 @@ cleanup: | |||
848 | return error; | 848 | return error; |
849 | 849 | ||
850 | cleanup_dquot: | 850 | cleanup_dquot: |
851 | DQUOT_FREE_BLOCK(inode, 1); | 851 | vfs_dq_free_block(inode, 1); |
852 | goto cleanup; | 852 | goto cleanup; |
853 | 853 | ||
854 | bad_block: | 854 | bad_block: |
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index de9459b4cb94..38f40d55899c 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -536,7 +536,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, | |||
536 | ext4_mb_free_blocks(handle, inode, block, count, | 536 | ext4_mb_free_blocks(handle, inode, block, count, |
537 | metadata, &dquot_freed_blocks); | 537 | metadata, &dquot_freed_blocks); |
538 | if (dquot_freed_blocks) | 538 | if (dquot_freed_blocks) |
539 | DQUOT_FREE_BLOCK(inode, dquot_freed_blocks); | 539 | vfs_dq_free_block(inode, dquot_freed_blocks); |
540 | return; | 540 | return; |
541 | } | 541 | } |
542 | 542 | ||
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index b0c87dce66a3..6083bb38057b 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/blkdev.h> | 20 | #include <linux/blkdev.h> |
21 | #include <linux/magic.h> | 21 | #include <linux/magic.h> |
22 | #include <linux/jbd2.h> | 22 | #include <linux/jbd2.h> |
23 | #include <linux/quota.h> | ||
23 | #include "ext4_i.h" | 24 | #include "ext4_i.h" |
24 | 25 | ||
25 | /* | 26 | /* |
@@ -1098,6 +1099,7 @@ extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks); | |||
1098 | extern int ext4_block_truncate_page(handle_t *handle, | 1099 | extern int ext4_block_truncate_page(handle_t *handle, |
1099 | struct address_space *mapping, loff_t from); | 1100 | struct address_space *mapping, loff_t from); |
1100 | extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page); | 1101 | extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page); |
1102 | extern qsize_t ext4_get_reserved_space(struct inode *inode); | ||
1101 | 1103 | ||
1102 | /* ioctl.c */ | 1104 | /* ioctl.c */ |
1103 | extern long ext4_ioctl(struct file *, unsigned int, unsigned long); | 1105 | extern long ext4_ioctl(struct file *, unsigned int, unsigned long); |
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 2d2b3585ee91..fb51b40e3e8f 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
@@ -220,10 +220,10 @@ void ext4_free_inode(handle_t *handle, struct inode *inode) | |||
220 | * Note: we must free any quota before locking the superblock, | 220 | * Note: we must free any quota before locking the superblock, |
221 | * as writing the quota to disk may need the lock as well. | 221 | * as writing the quota to disk may need the lock as well. |
222 | */ | 222 | */ |
223 | DQUOT_INIT(inode); | 223 | vfs_dq_init(inode); |
224 | ext4_xattr_delete_inode(handle, inode); | 224 | ext4_xattr_delete_inode(handle, inode); |
225 | DQUOT_FREE_INODE(inode); | 225 | vfs_dq_free_inode(inode); |
226 | DQUOT_DROP(inode); | 226 | vfs_dq_drop(inode); |
227 | 227 | ||
228 | is_directory = S_ISDIR(inode->i_mode); | 228 | is_directory = S_ISDIR(inode->i_mode); |
229 | 229 | ||
@@ -915,7 +915,7 @@ got: | |||
915 | ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; | 915 | ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; |
916 | 916 | ||
917 | ret = inode; | 917 | ret = inode; |
918 | if (DQUOT_ALLOC_INODE(inode)) { | 918 | if (vfs_dq_alloc_inode(inode)) { |
919 | err = -EDQUOT; | 919 | err = -EDQUOT; |
920 | goto fail_drop; | 920 | goto fail_drop; |
921 | } | 921 | } |
@@ -956,10 +956,10 @@ really_out: | |||
956 | return ret; | 956 | return ret; |
957 | 957 | ||
958 | fail_free_drop: | 958 | fail_free_drop: |
959 | DQUOT_FREE_INODE(inode); | 959 | vfs_dq_free_inode(inode); |
960 | 960 | ||
961 | fail_drop: | 961 | fail_drop: |
962 | DQUOT_DROP(inode); | 962 | vfs_dq_drop(inode); |
963 | inode->i_flags |= S_NOQUOTA; | 963 | inode->i_flags |= S_NOQUOTA; |
964 | inode->i_nlink = 0; | 964 | inode->i_nlink = 0; |
965 | unlock_new_inode(inode); | 965 | unlock_new_inode(inode); |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index c7fed5b18745..71d3ecd5db79 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -975,6 +975,17 @@ out: | |||
975 | return err; | 975 | return err; |
976 | } | 976 | } |
977 | 977 | ||
978 | qsize_t ext4_get_reserved_space(struct inode *inode) | ||
979 | { | ||
980 | unsigned long long total; | ||
981 | |||
982 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); | ||
983 | total = EXT4_I(inode)->i_reserved_data_blocks + | ||
984 | EXT4_I(inode)->i_reserved_meta_blocks; | ||
985 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | ||
986 | |||
987 | return total; | ||
988 | } | ||
978 | /* | 989 | /* |
979 | * Calculate the number of metadata blocks need to reserve | 990 | * Calculate the number of metadata blocks need to reserve |
980 | * to allocate @blocks for non extent file based file | 991 | * to allocate @blocks for non extent file based file |
@@ -1036,8 +1047,14 @@ static void ext4_da_update_reserve_space(struct inode *inode, int used) | |||
1036 | /* update per-inode reservations */ | 1047 | /* update per-inode reservations */ |
1037 | BUG_ON(used > EXT4_I(inode)->i_reserved_data_blocks); | 1048 | BUG_ON(used > EXT4_I(inode)->i_reserved_data_blocks); |
1038 | EXT4_I(inode)->i_reserved_data_blocks -= used; | 1049 | EXT4_I(inode)->i_reserved_data_blocks -= used; |
1039 | |||
1040 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | 1050 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); |
1051 | |||
1052 | /* | ||
1053 | * free those over-booking quota for metadata blocks | ||
1054 | */ | ||
1055 | |||
1056 | if (mdb_free) | ||
1057 | vfs_dq_release_reservation_block(inode, mdb_free); | ||
1041 | } | 1058 | } |
1042 | 1059 | ||
1043 | /* | 1060 | /* |
@@ -1553,8 +1570,8 @@ static int ext4_journalled_write_end(struct file *file, | |||
1553 | static int ext4_da_reserve_space(struct inode *inode, int nrblocks) | 1570 | static int ext4_da_reserve_space(struct inode *inode, int nrblocks) |
1554 | { | 1571 | { |
1555 | int retries = 0; | 1572 | int retries = 0; |
1556 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 1573 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
1557 | unsigned long md_needed, mdblocks, total = 0; | 1574 | unsigned long md_needed, mdblocks, total = 0; |
1558 | 1575 | ||
1559 | /* | 1576 | /* |
1560 | * recalculate the amount of metadata blocks to reserve | 1577 | * recalculate the amount of metadata blocks to reserve |
@@ -1570,12 +1587,23 @@ repeat: | |||
1570 | md_needed = mdblocks - EXT4_I(inode)->i_reserved_meta_blocks; | 1587 | md_needed = mdblocks - EXT4_I(inode)->i_reserved_meta_blocks; |
1571 | total = md_needed + nrblocks; | 1588 | total = md_needed + nrblocks; |
1572 | 1589 | ||
1590 | /* | ||
1591 | * Make quota reservation here to prevent quota overflow | ||
1592 | * later. Real quota accounting is done at pages writeout | ||
1593 | * time. | ||
1594 | */ | ||
1595 | if (vfs_dq_reserve_block(inode, total)) { | ||
1596 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | ||
1597 | return -EDQUOT; | ||
1598 | } | ||
1599 | |||
1573 | if (ext4_claim_free_blocks(sbi, total)) { | 1600 | if (ext4_claim_free_blocks(sbi, total)) { |
1574 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | 1601 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); |
1575 | if (ext4_should_retry_alloc(inode->i_sb, &retries)) { | 1602 | if (ext4_should_retry_alloc(inode->i_sb, &retries)) { |
1576 | yield(); | 1603 | yield(); |
1577 | goto repeat; | 1604 | goto repeat; |
1578 | } | 1605 | } |
1606 | vfs_dq_release_reservation_block(inode, total); | ||
1579 | return -ENOSPC; | 1607 | return -ENOSPC; |
1580 | } | 1608 | } |
1581 | EXT4_I(inode)->i_reserved_data_blocks += nrblocks; | 1609 | EXT4_I(inode)->i_reserved_data_blocks += nrblocks; |
@@ -1629,6 +1657,8 @@ static void ext4_da_release_space(struct inode *inode, int to_free) | |||
1629 | BUG_ON(mdb > EXT4_I(inode)->i_reserved_meta_blocks); | 1657 | BUG_ON(mdb > EXT4_I(inode)->i_reserved_meta_blocks); |
1630 | EXT4_I(inode)->i_reserved_meta_blocks = mdb; | 1658 | EXT4_I(inode)->i_reserved_meta_blocks = mdb; |
1631 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | 1659 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); |
1660 | |||
1661 | vfs_dq_release_reservation_block(inode, release); | ||
1632 | } | 1662 | } |
1633 | 1663 | ||
1634 | static void ext4_da_page_release_reservation(struct page *page, | 1664 | static void ext4_da_page_release_reservation(struct page *page, |
@@ -4612,7 +4642,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) | |||
4612 | error = PTR_ERR(handle); | 4642 | error = PTR_ERR(handle); |
4613 | goto err_out; | 4643 | goto err_out; |
4614 | } | 4644 | } |
4615 | error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0; | 4645 | error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0; |
4616 | if (error) { | 4646 | if (error) { |
4617 | ext4_journal_stop(handle); | 4647 | ext4_journal_stop(handle); |
4618 | return error; | 4648 | return error; |
@@ -4991,7 +5021,7 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode) | |||
4991 | * i_size has been changed by generic_commit_write() and we thus need | 5021 | * i_size has been changed by generic_commit_write() and we thus need |
4992 | * to include the updated inode in the current transaction. | 5022 | * to include the updated inode in the current transaction. |
4993 | * | 5023 | * |
4994 | * Also, DQUOT_ALLOC_SPACE() will always dirty the inode when blocks | 5024 | * Also, vfs_dq_alloc_block() will always dirty the inode when blocks |
4995 | * are allocated to the file. | 5025 | * are allocated to the file. |
4996 | * | 5026 | * |
4997 | * If the inode is marked synchronous, we don't honour that here - doing | 5027 | * If the inode is marked synchronous, we don't honour that here - doing |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 9f61e62f435f..b038188bd039 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -3086,9 +3086,12 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, | |||
3086 | if (!(ac->ac_flags & EXT4_MB_DELALLOC_RESERVED)) | 3086 | if (!(ac->ac_flags & EXT4_MB_DELALLOC_RESERVED)) |
3087 | /* release all the reserved blocks if non delalloc */ | 3087 | /* release all the reserved blocks if non delalloc */ |
3088 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, reserv_blks); | 3088 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, reserv_blks); |
3089 | else | 3089 | else { |
3090 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, | 3090 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, |
3091 | ac->ac_b_ex.fe_len); | 3091 | ac->ac_b_ex.fe_len); |
3092 | /* convert reserved quota blocks to real quota blocks */ | ||
3093 | vfs_dq_claim_block(ac->ac_inode, ac->ac_b_ex.fe_len); | ||
3094 | } | ||
3092 | 3095 | ||
3093 | if (sbi->s_log_groups_per_flex) { | 3096 | if (sbi->s_log_groups_per_flex) { |
3094 | ext4_group_t flex_group = ext4_flex_group(sbi, | 3097 | ext4_group_t flex_group = ext4_flex_group(sbi, |
@@ -4544,7 +4547,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | |||
4544 | struct ext4_sb_info *sbi; | 4547 | struct ext4_sb_info *sbi; |
4545 | struct super_block *sb; | 4548 | struct super_block *sb; |
4546 | ext4_fsblk_t block = 0; | 4549 | ext4_fsblk_t block = 0; |
4547 | unsigned int inquota; | 4550 | unsigned int inquota = 0; |
4548 | unsigned int reserv_blks = 0; | 4551 | unsigned int reserv_blks = 0; |
4549 | 4552 | ||
4550 | sb = ar->inode->i_sb; | 4553 | sb = ar->inode->i_sb; |
@@ -4562,9 +4565,17 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | |||
4562 | (unsigned long long) ar->pleft, | 4565 | (unsigned long long) ar->pleft, |
4563 | (unsigned long long) ar->pright); | 4566 | (unsigned long long) ar->pright); |
4564 | 4567 | ||
4565 | if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag) { | 4568 | /* |
4566 | /* | 4569 | * For delayed allocation, we could skip the ENOSPC and |
4567 | * With delalloc we already reserved the blocks | 4570 | * EDQUOT check, as blocks and quotas have been already |
4571 | * reserved when data being copied into pagecache. | ||
4572 | */ | ||
4573 | if (EXT4_I(ar->inode)->i_delalloc_reserved_flag) | ||
4574 | ar->flags |= EXT4_MB_DELALLOC_RESERVED; | ||
4575 | else { | ||
4576 | /* Without delayed allocation we need to verify | ||
4577 | * there is enough free blocks to do block allocation | ||
4578 | * and verify allocation doesn't exceed the quota limits. | ||
4568 | */ | 4579 | */ |
4569 | while (ar->len && ext4_claim_free_blocks(sbi, ar->len)) { | 4580 | while (ar->len && ext4_claim_free_blocks(sbi, ar->len)) { |
4570 | /* let others to free the space */ | 4581 | /* let others to free the space */ |
@@ -4576,19 +4587,16 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | |||
4576 | return 0; | 4587 | return 0; |
4577 | } | 4588 | } |
4578 | reserv_blks = ar->len; | 4589 | reserv_blks = ar->len; |
4590 | while (ar->len && vfs_dq_alloc_block(ar->inode, ar->len)) { | ||
4591 | ar->flags |= EXT4_MB_HINT_NOPREALLOC; | ||
4592 | ar->len--; | ||
4593 | } | ||
4594 | inquota = ar->len; | ||
4595 | if (ar->len == 0) { | ||
4596 | *errp = -EDQUOT; | ||
4597 | goto out3; | ||
4598 | } | ||
4579 | } | 4599 | } |
4580 | while (ar->len && DQUOT_ALLOC_BLOCK(ar->inode, ar->len)) { | ||
4581 | ar->flags |= EXT4_MB_HINT_NOPREALLOC; | ||
4582 | ar->len--; | ||
4583 | } | ||
4584 | if (ar->len == 0) { | ||
4585 | *errp = -EDQUOT; | ||
4586 | goto out3; | ||
4587 | } | ||
4588 | inquota = ar->len; | ||
4589 | |||
4590 | if (EXT4_I(ar->inode)->i_delalloc_reserved_flag) | ||
4591 | ar->flags |= EXT4_MB_DELALLOC_RESERVED; | ||
4592 | 4600 | ||
4593 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); | 4601 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); |
4594 | if (!ac) { | 4602 | if (!ac) { |
@@ -4654,8 +4662,8 @@ repeat: | |||
4654 | out2: | 4662 | out2: |
4655 | kmem_cache_free(ext4_ac_cachep, ac); | 4663 | kmem_cache_free(ext4_ac_cachep, ac); |
4656 | out1: | 4664 | out1: |
4657 | if (ar->len < inquota) | 4665 | if (inquota && ar->len < inquota) |
4658 | DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len); | 4666 | vfs_dq_free_block(ar->inode, inquota - ar->len); |
4659 | out3: | 4667 | out3: |
4660 | if (!ar->len) { | 4668 | if (!ar->len) { |
4661 | if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag) | 4669 | if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag) |
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index ba702bd7910d..83410244d3ee 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -2092,7 +2092,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) | |||
2092 | 2092 | ||
2093 | /* Initialize quotas before so that eventual writes go in | 2093 | /* Initialize quotas before so that eventual writes go in |
2094 | * separate transaction */ | 2094 | * separate transaction */ |
2095 | DQUOT_INIT(dentry->d_inode); | 2095 | vfs_dq_init(dentry->d_inode); |
2096 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2096 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); |
2097 | if (IS_ERR(handle)) | 2097 | if (IS_ERR(handle)) |
2098 | return PTR_ERR(handle); | 2098 | return PTR_ERR(handle); |
@@ -2151,7 +2151,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) | |||
2151 | 2151 | ||
2152 | /* Initialize quotas before so that eventual writes go | 2152 | /* Initialize quotas before so that eventual writes go |
2153 | * in separate transaction */ | 2153 | * in separate transaction */ |
2154 | DQUOT_INIT(dentry->d_inode); | 2154 | vfs_dq_init(dentry->d_inode); |
2155 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2155 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); |
2156 | if (IS_ERR(handle)) | 2156 | if (IS_ERR(handle)) |
2157 | return PTR_ERR(handle); | 2157 | return PTR_ERR(handle); |
@@ -2318,7 +2318,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2318 | /* Initialize quotas before so that eventual writes go | 2318 | /* Initialize quotas before so that eventual writes go |
2319 | * in separate transaction */ | 2319 | * in separate transaction */ |
2320 | if (new_dentry->d_inode) | 2320 | if (new_dentry->d_inode) |
2321 | DQUOT_INIT(new_dentry->d_inode); | 2321 | vfs_dq_init(new_dentry->d_inode); |
2322 | handle = ext4_journal_start(old_dir, 2 * | 2322 | handle = ext4_journal_start(old_dir, 2 * |
2323 | EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) + | 2323 | EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) + |
2324 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2); | 2324 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2); |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 39d1993cfa13..f7371a6a923d 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -926,8 +926,6 @@ static int bdev_try_to_free_page(struct super_block *sb, struct page *page, gfp_ | |||
926 | #define QTYPE2NAME(t) ((t) == USRQUOTA ? "user" : "group") | 926 | #define QTYPE2NAME(t) ((t) == USRQUOTA ? "user" : "group") |
927 | #define QTYPE2MOPT(on, t) ((t) == USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) | 927 | #define QTYPE2MOPT(on, t) ((t) == USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) |
928 | 928 | ||
929 | static int ext4_dquot_initialize(struct inode *inode, int type); | ||
930 | static int ext4_dquot_drop(struct inode *inode); | ||
931 | static int ext4_write_dquot(struct dquot *dquot); | 929 | static int ext4_write_dquot(struct dquot *dquot); |
932 | static int ext4_acquire_dquot(struct dquot *dquot); | 930 | static int ext4_acquire_dquot(struct dquot *dquot); |
933 | static int ext4_release_dquot(struct dquot *dquot); | 931 | static int ext4_release_dquot(struct dquot *dquot); |
@@ -942,9 +940,13 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, | |||
942 | const char *data, size_t len, loff_t off); | 940 | const char *data, size_t len, loff_t off); |
943 | 941 | ||
944 | static struct dquot_operations ext4_quota_operations = { | 942 | static struct dquot_operations ext4_quota_operations = { |
945 | .initialize = ext4_dquot_initialize, | 943 | .initialize = dquot_initialize, |
946 | .drop = ext4_dquot_drop, | 944 | .drop = dquot_drop, |
947 | .alloc_space = dquot_alloc_space, | 945 | .alloc_space = dquot_alloc_space, |
946 | .reserve_space = dquot_reserve_space, | ||
947 | .claim_space = dquot_claim_space, | ||
948 | .release_rsv = dquot_release_reserved_space, | ||
949 | .get_reserved_space = ext4_get_reserved_space, | ||
948 | .alloc_inode = dquot_alloc_inode, | 950 | .alloc_inode = dquot_alloc_inode, |
949 | .free_space = dquot_free_space, | 951 | .free_space = dquot_free_space, |
950 | .free_inode = dquot_free_inode, | 952 | .free_inode = dquot_free_inode, |
@@ -1802,7 +1804,7 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1802 | } | 1804 | } |
1803 | 1805 | ||
1804 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); | 1806 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); |
1805 | DQUOT_INIT(inode); | 1807 | vfs_dq_init(inode); |
1806 | if (inode->i_nlink) { | 1808 | if (inode->i_nlink) { |
1807 | printk(KERN_DEBUG | 1809 | printk(KERN_DEBUG |
1808 | "%s: truncating inode %lu to %lld bytes\n", | 1810 | "%s: truncating inode %lu to %lld bytes\n", |
@@ -3367,8 +3369,8 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
3367 | * is locked for write. Otherwise the are possible deadlocks: | 3369 | * is locked for write. Otherwise the are possible deadlocks: |
3368 | * Process 1 Process 2 | 3370 | * Process 1 Process 2 |
3369 | * ext4_create() quota_sync() | 3371 | * ext4_create() quota_sync() |
3370 | * jbd2_journal_start() write_dquot() | 3372 | * jbd2_journal_start() write_dquot() |
3371 | * DQUOT_INIT() down(dqio_mutex) | 3373 | * vfs_dq_init() down(dqio_mutex) |
3372 | * down(dqio_mutex) jbd2_journal_start() | 3374 | * down(dqio_mutex) jbd2_journal_start() |
3373 | * | 3375 | * |
3374 | */ | 3376 | */ |
@@ -3380,44 +3382,6 @@ static inline struct inode *dquot_to_inode(struct dquot *dquot) | |||
3380 | return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type]; | 3382 | return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type]; |
3381 | } | 3383 | } |
3382 | 3384 | ||
3383 | static int ext4_dquot_initialize(struct inode *inode, int type) | ||
3384 | { | ||
3385 | handle_t *handle; | ||
3386 | int ret, err; | ||
3387 | |||
3388 | /* We may create quota structure so we need to reserve enough blocks */ | ||
3389 | handle = ext4_journal_start(inode, 2*EXT4_QUOTA_INIT_BLOCKS(inode->i_sb)); | ||
3390 | if (IS_ERR(handle)) | ||
3391 | return PTR_ERR(handle); | ||
3392 | ret = dquot_initialize(inode, type); | ||
3393 | err = ext4_journal_stop(handle); | ||
3394 | if (!ret) | ||
3395 | ret = err; | ||
3396 | return ret; | ||
3397 | } | ||
3398 | |||
3399 | static int ext4_dquot_drop(struct inode *inode) | ||
3400 | { | ||
3401 | handle_t *handle; | ||
3402 | int ret, err; | ||
3403 | |||
3404 | /* We may delete quota structure so we need to reserve enough blocks */ | ||
3405 | handle = ext4_journal_start(inode, 2*EXT4_QUOTA_DEL_BLOCKS(inode->i_sb)); | ||
3406 | if (IS_ERR(handle)) { | ||
3407 | /* | ||
3408 | * We call dquot_drop() anyway to at least release references | ||
3409 | * to quota structures so that umount does not hang. | ||
3410 | */ | ||
3411 | dquot_drop(inode); | ||
3412 | return PTR_ERR(handle); | ||
3413 | } | ||
3414 | ret = dquot_drop(inode); | ||
3415 | err = ext4_journal_stop(handle); | ||
3416 | if (!ret) | ||
3417 | ret = err; | ||
3418 | return ret; | ||
3419 | } | ||
3420 | |||
3421 | static int ext4_write_dquot(struct dquot *dquot) | 3385 | static int ext4_write_dquot(struct dquot *dquot) |
3422 | { | 3386 | { |
3423 | int ret, err; | 3387 | int ret, err; |
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 157ce6589c54..62b31c246994 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -490,7 +490,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode, | |||
490 | error = ext4_handle_dirty_metadata(handle, inode, bh); | 490 | error = ext4_handle_dirty_metadata(handle, inode, bh); |
491 | if (IS_SYNC(inode)) | 491 | if (IS_SYNC(inode)) |
492 | ext4_handle_sync(handle); | 492 | ext4_handle_sync(handle); |
493 | DQUOT_FREE_BLOCK(inode, 1); | 493 | vfs_dq_free_block(inode, 1); |
494 | ea_bdebug(bh, "refcount now=%d; releasing", | 494 | ea_bdebug(bh, "refcount now=%d; releasing", |
495 | le32_to_cpu(BHDR(bh)->h_refcount)); | 495 | le32_to_cpu(BHDR(bh)->h_refcount)); |
496 | if (ce) | 496 | if (ce) |
@@ -784,7 +784,7 @@ inserted: | |||
784 | /* The old block is released after updating | 784 | /* The old block is released after updating |
785 | the inode. */ | 785 | the inode. */ |
786 | error = -EDQUOT; | 786 | error = -EDQUOT; |
787 | if (DQUOT_ALLOC_BLOCK(inode, 1)) | 787 | if (vfs_dq_alloc_block(inode, 1)) |
788 | goto cleanup; | 788 | goto cleanup; |
789 | error = ext4_journal_get_write_access(handle, | 789 | error = ext4_journal_get_write_access(handle, |
790 | new_bh); | 790 | new_bh); |
@@ -860,7 +860,7 @@ cleanup: | |||
860 | return error; | 860 | return error; |
861 | 861 | ||
862 | cleanup_dquot: | 862 | cleanup_dquot: |
863 | DQUOT_FREE_BLOCK(inode, 1); | 863 | vfs_dq_free_block(inode, 1); |
864 | goto cleanup; | 864 | goto cleanup; |
865 | 865 | ||
866 | bad_block: | 866 | bad_block: |
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c index 7ba03a4acbe0..da3f361a37dd 100644 --- a/fs/fat/namei_msdos.c +++ b/fs/fat/namei_msdos.c | |||
@@ -188,7 +188,7 @@ old_compare: | |||
188 | goto out; | 188 | goto out; |
189 | } | 189 | } |
190 | 190 | ||
191 | static struct dentry_operations msdos_dentry_operations = { | 191 | static const struct dentry_operations msdos_dentry_operations = { |
192 | .d_hash = msdos_hash, | 192 | .d_hash = msdos_hash, |
193 | .d_compare = msdos_cmp, | 193 | .d_compare = msdos_cmp, |
194 | }; | 194 | }; |
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index 8ae32e37673c..a0e00e3a46e9 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c | |||
@@ -166,13 +166,13 @@ static int vfat_cmp(struct dentry *dentry, struct qstr *a, struct qstr *b) | |||
166 | return 1; | 166 | return 1; |
167 | } | 167 | } |
168 | 168 | ||
169 | static struct dentry_operations vfat_ci_dentry_ops = { | 169 | static const struct dentry_operations vfat_ci_dentry_ops = { |
170 | .d_revalidate = vfat_revalidate_ci, | 170 | .d_revalidate = vfat_revalidate_ci, |
171 | .d_hash = vfat_hashi, | 171 | .d_hash = vfat_hashi, |
172 | .d_compare = vfat_cmpi, | 172 | .d_compare = vfat_cmpi, |
173 | }; | 173 | }; |
174 | 174 | ||
175 | static struct dentry_operations vfat_dentry_ops = { | 175 | static const struct dentry_operations vfat_dentry_ops = { |
176 | .d_revalidate = vfat_revalidate, | 176 | .d_revalidate = vfat_revalidate, |
177 | .d_hash = vfat_hash, | 177 | .d_hash = vfat_hash, |
178 | .d_compare = vfat_cmp, | 178 | .d_compare = vfat_cmp, |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index fdff346e96fd..06da05261e04 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -224,7 +224,7 @@ static int invalid_nodeid(u64 nodeid) | |||
224 | return !nodeid || nodeid == FUSE_ROOT_ID; | 224 | return !nodeid || nodeid == FUSE_ROOT_ID; |
225 | } | 225 | } |
226 | 226 | ||
227 | struct dentry_operations fuse_dentry_operations = { | 227 | const struct dentry_operations fuse_dentry_operations = { |
228 | .d_revalidate = fuse_dentry_revalidate, | 228 | .d_revalidate = fuse_dentry_revalidate, |
229 | }; | 229 | }; |
230 | 230 | ||
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 5e64b815a5a1..6fc5aedaa0d5 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -493,7 +493,7 @@ static inline u64 get_node_id(struct inode *inode) | |||
493 | /** Device operations */ | 493 | /** Device operations */ |
494 | extern const struct file_operations fuse_dev_operations; | 494 | extern const struct file_operations fuse_dev_operations; |
495 | 495 | ||
496 | extern struct dentry_operations fuse_dentry_operations; | 496 | extern const struct dentry_operations fuse_dentry_operations; |
497 | 497 | ||
498 | /** | 498 | /** |
499 | * Get a filled in inode | 499 | * Get a filled in inode |
diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c index 5eb57b044382..022c66cd5606 100644 --- a/fs/gfs2/ops_dentry.c +++ b/fs/gfs2/ops_dentry.c | |||
@@ -107,7 +107,7 @@ static int gfs2_dhash(struct dentry *dentry, struct qstr *str) | |||
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | struct dentry_operations gfs2_dops = { | 110 | const struct dentry_operations gfs2_dops = { |
111 | .d_revalidate = gfs2_drevalidate, | 111 | .d_revalidate = gfs2_drevalidate, |
112 | .d_hash = gfs2_dhash, | 112 | .d_hash = gfs2_dhash, |
113 | }; | 113 | }; |
diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h index 91abdbedcc86..b56413e3e40d 100644 --- a/fs/gfs2/super.h +++ b/fs/gfs2/super.h | |||
@@ -49,7 +49,7 @@ extern struct file_system_type gfs2_fs_type; | |||
49 | extern struct file_system_type gfs2meta_fs_type; | 49 | extern struct file_system_type gfs2meta_fs_type; |
50 | extern const struct export_operations gfs2_export_ops; | 50 | extern const struct export_operations gfs2_export_ops; |
51 | extern const struct super_operations gfs2_super_ops; | 51 | extern const struct super_operations gfs2_super_ops; |
52 | extern struct dentry_operations gfs2_dops; | 52 | extern const struct dentry_operations gfs2_dops; |
53 | 53 | ||
54 | #endif /* __SUPER_DOT_H__ */ | 54 | #endif /* __SUPER_DOT_H__ */ |
55 | 55 | ||
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h index 9955232fdf8c..052387e11671 100644 --- a/fs/hfs/hfs_fs.h +++ b/fs/hfs/hfs_fs.h | |||
@@ -213,7 +213,7 @@ extern void hfs_mdb_put(struct super_block *); | |||
213 | extern int hfs_part_find(struct super_block *, sector_t *, sector_t *); | 213 | extern int hfs_part_find(struct super_block *, sector_t *, sector_t *); |
214 | 214 | ||
215 | /* string.c */ | 215 | /* string.c */ |
216 | extern struct dentry_operations hfs_dentry_operations; | 216 | extern const struct dentry_operations hfs_dentry_operations; |
217 | 217 | ||
218 | extern int hfs_hash_dentry(struct dentry *, struct qstr *); | 218 | extern int hfs_hash_dentry(struct dentry *, struct qstr *); |
219 | extern int hfs_strcmp(const unsigned char *, unsigned int, | 219 | extern int hfs_strcmp(const unsigned char *, unsigned int, |
diff --git a/fs/hfs/sysdep.c b/fs/hfs/sysdep.c index 5bf89ec01cd4..7478f5c219aa 100644 --- a/fs/hfs/sysdep.c +++ b/fs/hfs/sysdep.c | |||
@@ -31,7 +31,7 @@ static int hfs_revalidate_dentry(struct dentry *dentry, struct nameidata *nd) | |||
31 | return 1; | 31 | return 1; |
32 | } | 32 | } |
33 | 33 | ||
34 | struct dentry_operations hfs_dentry_operations = | 34 | const struct dentry_operations hfs_dentry_operations = |
35 | { | 35 | { |
36 | .d_revalidate = hfs_revalidate_dentry, | 36 | .d_revalidate = hfs_revalidate_dentry, |
37 | .d_hash = hfs_hash_dentry, | 37 | .d_hash = hfs_hash_dentry, |
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index f027a905225f..5c10d803d9df 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h | |||
@@ -327,7 +327,7 @@ void hfsplus_file_truncate(struct inode *); | |||
327 | /* inode.c */ | 327 | /* inode.c */ |
328 | extern const struct address_space_operations hfsplus_aops; | 328 | extern const struct address_space_operations hfsplus_aops; |
329 | extern const struct address_space_operations hfsplus_btree_aops; | 329 | extern const struct address_space_operations hfsplus_btree_aops; |
330 | extern struct dentry_operations hfsplus_dentry_operations; | 330 | extern const struct dentry_operations hfsplus_dentry_operations; |
331 | 331 | ||
332 | void hfsplus_inode_read_fork(struct inode *, struct hfsplus_fork_raw *); | 332 | void hfsplus_inode_read_fork(struct inode *, struct hfsplus_fork_raw *); |
333 | void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *); | 333 | void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *); |
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index f105ee9e1cc4..1bcf597c0562 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c | |||
@@ -137,7 +137,7 @@ const struct address_space_operations hfsplus_aops = { | |||
137 | .writepages = hfsplus_writepages, | 137 | .writepages = hfsplus_writepages, |
138 | }; | 138 | }; |
139 | 139 | ||
140 | struct dentry_operations hfsplus_dentry_operations = { | 140 | const struct dentry_operations hfsplus_dentry_operations = { |
141 | .d_hash = hfsplus_hash_dentry, | 141 | .d_hash = hfsplus_hash_dentry, |
142 | .d_compare = hfsplus_compare_dentry, | 142 | .d_compare = hfsplus_compare_dentry, |
143 | }; | 143 | }; |
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 5c538e0ec14b..fe02ad4740e7 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -31,12 +31,12 @@ static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode) | |||
31 | 31 | ||
32 | #define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_path.dentry->d_inode) | 32 | #define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_path.dentry->d_inode) |
33 | 33 | ||
34 | int hostfs_d_delete(struct dentry *dentry) | 34 | static int hostfs_d_delete(struct dentry *dentry) |
35 | { | 35 | { |
36 | return 1; | 36 | return 1; |
37 | } | 37 | } |
38 | 38 | ||
39 | struct dentry_operations hostfs_dentry_ops = { | 39 | static const struct dentry_operations hostfs_dentry_ops = { |
40 | .d_delete = hostfs_d_delete, | 40 | .d_delete = hostfs_d_delete, |
41 | }; | 41 | }; |
42 | 42 | ||
diff --git a/fs/hpfs/dentry.c b/fs/hpfs/dentry.c index 08319126b2af..940d6d150bee 100644 --- a/fs/hpfs/dentry.c +++ b/fs/hpfs/dentry.c | |||
@@ -49,7 +49,7 @@ static int hpfs_compare_dentry(struct dentry *dentry, struct qstr *a, struct qst | |||
49 | return 0; | 49 | return 0; |
50 | } | 50 | } |
51 | 51 | ||
52 | static struct dentry_operations hpfs_dentry_operations = { | 52 | static const struct dentry_operations hpfs_dentry_operations = { |
53 | .d_hash = hpfs_hash_dentry, | 53 | .d_hash = hpfs_hash_dentry, |
54 | .d_compare = hpfs_compare_dentry, | 54 | .d_compare = hpfs_compare_dentry, |
55 | }; | 55 | }; |
diff --git a/fs/inode.c b/fs/inode.c index 643ac43e5a5c..d06d6d268de9 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -294,7 +294,7 @@ void clear_inode(struct inode *inode) | |||
294 | BUG_ON(!(inode->i_state & I_FREEING)); | 294 | BUG_ON(!(inode->i_state & I_FREEING)); |
295 | BUG_ON(inode->i_state & I_CLEAR); | 295 | BUG_ON(inode->i_state & I_CLEAR); |
296 | inode_sync_wait(inode); | 296 | inode_sync_wait(inode); |
297 | DQUOT_DROP(inode); | 297 | vfs_dq_drop(inode); |
298 | if (inode->i_sb->s_op->clear_inode) | 298 | if (inode->i_sb->s_op->clear_inode) |
299 | inode->i_sb->s_op->clear_inode(inode); | 299 | inode->i_sb->s_op->clear_inode(inode); |
300 | if (S_ISBLK(inode->i_mode) && inode->i_bdev) | 300 | if (S_ISBLK(inode->i_mode) && inode->i_bdev) |
@@ -366,6 +366,8 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose) | |||
366 | if (tmp == head) | 366 | if (tmp == head) |
367 | break; | 367 | break; |
368 | inode = list_entry(tmp, struct inode, i_sb_list); | 368 | inode = list_entry(tmp, struct inode, i_sb_list); |
369 | if (inode->i_state & I_NEW) | ||
370 | continue; | ||
369 | invalidate_inode_buffers(inode); | 371 | invalidate_inode_buffers(inode); |
370 | if (!atomic_read(&inode->i_count)) { | 372 | if (!atomic_read(&inode->i_count)) { |
371 | list_move(&inode->i_list, dispose); | 373 | list_move(&inode->i_list, dispose); |
@@ -1168,7 +1170,7 @@ void generic_delete_inode(struct inode *inode) | |||
1168 | if (op->delete_inode) { | 1170 | if (op->delete_inode) { |
1169 | void (*delete)(struct inode *) = op->delete_inode; | 1171 | void (*delete)(struct inode *) = op->delete_inode; |
1170 | if (!is_bad_inode(inode)) | 1172 | if (!is_bad_inode(inode)) |
1171 | DQUOT_INIT(inode); | 1173 | vfs_dq_init(inode); |
1172 | /* Filesystems implementing their own | 1174 | /* Filesystems implementing their own |
1173 | * s_op->delete_inode are required to call | 1175 | * s_op->delete_inode are required to call |
1174 | * truncate_inode_pages and clear_inode() | 1176 | * truncate_inode_pages and clear_inode() |
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 6147ec3643a0..13d2eddd0692 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c | |||
@@ -114,7 +114,7 @@ static const struct super_operations isofs_sops = { | |||
114 | }; | 114 | }; |
115 | 115 | ||
116 | 116 | ||
117 | static struct dentry_operations isofs_dentry_ops[] = { | 117 | static const struct dentry_operations isofs_dentry_ops[] = { |
118 | { | 118 | { |
119 | .d_hash = isofs_hash, | 119 | .d_hash = isofs_hash, |
120 | .d_compare = isofs_dentry_cmp, | 120 | .d_compare = isofs_dentry_cmp, |
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c index d3e5c33665de..a166c1669e82 100644 --- a/fs/jfs/acl.c +++ b/fs/jfs/acl.c | |||
@@ -233,7 +233,7 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr) | |||
233 | 233 | ||
234 | if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) || | 234 | if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) || |
235 | (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) { | 235 | (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) { |
236 | if (DQUOT_TRANSFER(inode, iattr)) | 236 | if (vfs_dq_transfer(inode, iattr)) |
237 | return -EDQUOT; | 237 | return -EDQUOT; |
238 | } | 238 | } |
239 | 239 | ||
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index b00ee9f05a06..b2ae190a77ba 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c | |||
@@ -158,9 +158,9 @@ void jfs_delete_inode(struct inode *inode) | |||
158 | /* | 158 | /* |
159 | * Free the inode from the quota allocation. | 159 | * Free the inode from the quota allocation. |
160 | */ | 160 | */ |
161 | DQUOT_INIT(inode); | 161 | vfs_dq_init(inode); |
162 | DQUOT_FREE_INODE(inode); | 162 | vfs_dq_free_inode(inode); |
163 | DQUOT_DROP(inode); | 163 | vfs_dq_drop(inode); |
164 | } | 164 | } |
165 | 165 | ||
166 | clear_inode(inode); | 166 | clear_inode(inode); |
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c index 4dcc05819998..925871e9887b 100644 --- a/fs/jfs/jfs_dtree.c +++ b/fs/jfs/jfs_dtree.c | |||
@@ -381,10 +381,10 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot) | |||
381 | * It's time to move the inline table to an external | 381 | * It's time to move the inline table to an external |
382 | * page and begin to build the xtree | 382 | * page and begin to build the xtree |
383 | */ | 383 | */ |
384 | if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage)) | 384 | if (vfs_dq_alloc_block(ip, sbi->nbperpage)) |
385 | goto clean_up; | 385 | goto clean_up; |
386 | if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) { | 386 | if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) { |
387 | DQUOT_FREE_BLOCK(ip, sbi->nbperpage); | 387 | vfs_dq_free_block(ip, sbi->nbperpage); |
388 | goto clean_up; | 388 | goto clean_up; |
389 | } | 389 | } |
390 | 390 | ||
@@ -408,7 +408,7 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot) | |||
408 | memcpy(&jfs_ip->i_dirtable, temp_table, | 408 | memcpy(&jfs_ip->i_dirtable, temp_table, |
409 | sizeof (temp_table)); | 409 | sizeof (temp_table)); |
410 | dbFree(ip, xaddr, sbi->nbperpage); | 410 | dbFree(ip, xaddr, sbi->nbperpage); |
411 | DQUOT_FREE_BLOCK(ip, sbi->nbperpage); | 411 | vfs_dq_free_block(ip, sbi->nbperpage); |
412 | goto clean_up; | 412 | goto clean_up; |
413 | } | 413 | } |
414 | ip->i_size = PSIZE; | 414 | ip->i_size = PSIZE; |
@@ -1027,7 +1027,7 @@ static int dtSplitUp(tid_t tid, | |||
1027 | n = xlen; | 1027 | n = xlen; |
1028 | 1028 | ||
1029 | /* Allocate blocks to quota. */ | 1029 | /* Allocate blocks to quota. */ |
1030 | if (DQUOT_ALLOC_BLOCK(ip, n)) { | 1030 | if (vfs_dq_alloc_block(ip, n)) { |
1031 | rc = -EDQUOT; | 1031 | rc = -EDQUOT; |
1032 | goto extendOut; | 1032 | goto extendOut; |
1033 | } | 1033 | } |
@@ -1308,7 +1308,7 @@ static int dtSplitUp(tid_t tid, | |||
1308 | 1308 | ||
1309 | /* Rollback quota allocation */ | 1309 | /* Rollback quota allocation */ |
1310 | if (rc && quota_allocation) | 1310 | if (rc && quota_allocation) |
1311 | DQUOT_FREE_BLOCK(ip, quota_allocation); | 1311 | vfs_dq_free_block(ip, quota_allocation); |
1312 | 1312 | ||
1313 | dtSplitUp_Exit: | 1313 | dtSplitUp_Exit: |
1314 | 1314 | ||
@@ -1369,7 +1369,7 @@ static int dtSplitPage(tid_t tid, struct inode *ip, struct dtsplit * split, | |||
1369 | return -EIO; | 1369 | return -EIO; |
1370 | 1370 | ||
1371 | /* Allocate blocks to quota. */ | 1371 | /* Allocate blocks to quota. */ |
1372 | if (DQUOT_ALLOC_BLOCK(ip, lengthPXD(pxd))) { | 1372 | if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { |
1373 | release_metapage(rmp); | 1373 | release_metapage(rmp); |
1374 | return -EDQUOT; | 1374 | return -EDQUOT; |
1375 | } | 1375 | } |
@@ -1916,7 +1916,7 @@ static int dtSplitRoot(tid_t tid, | |||
1916 | rp = rmp->data; | 1916 | rp = rmp->data; |
1917 | 1917 | ||
1918 | /* Allocate blocks to quota. */ | 1918 | /* Allocate blocks to quota. */ |
1919 | if (DQUOT_ALLOC_BLOCK(ip, lengthPXD(pxd))) { | 1919 | if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { |
1920 | release_metapage(rmp); | 1920 | release_metapage(rmp); |
1921 | return -EDQUOT; | 1921 | return -EDQUOT; |
1922 | } | 1922 | } |
@@ -2287,7 +2287,7 @@ static int dtDeleteUp(tid_t tid, struct inode *ip, | |||
2287 | xlen = lengthPXD(&fp->header.self); | 2287 | xlen = lengthPXD(&fp->header.self); |
2288 | 2288 | ||
2289 | /* Free quota allocation. */ | 2289 | /* Free quota allocation. */ |
2290 | DQUOT_FREE_BLOCK(ip, xlen); | 2290 | vfs_dq_free_block(ip, xlen); |
2291 | 2291 | ||
2292 | /* free/invalidate its buffer page */ | 2292 | /* free/invalidate its buffer page */ |
2293 | discard_metapage(fmp); | 2293 | discard_metapage(fmp); |
@@ -2363,7 +2363,7 @@ static int dtDeleteUp(tid_t tid, struct inode *ip, | |||
2363 | xlen = lengthPXD(&p->header.self); | 2363 | xlen = lengthPXD(&p->header.self); |
2364 | 2364 | ||
2365 | /* Free quota allocation */ | 2365 | /* Free quota allocation */ |
2366 | DQUOT_FREE_BLOCK(ip, xlen); | 2366 | vfs_dq_free_block(ip, xlen); |
2367 | 2367 | ||
2368 | /* free/invalidate its buffer page */ | 2368 | /* free/invalidate its buffer page */ |
2369 | discard_metapage(mp); | 2369 | discard_metapage(mp); |
diff --git a/fs/jfs/jfs_extent.c b/fs/jfs/jfs_extent.c index 7ae1e3281de9..169802ea07f9 100644 --- a/fs/jfs/jfs_extent.c +++ b/fs/jfs/jfs_extent.c | |||
@@ -141,7 +141,7 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr) | |||
141 | } | 141 | } |
142 | 142 | ||
143 | /* Allocate blocks to quota. */ | 143 | /* Allocate blocks to quota. */ |
144 | if (DQUOT_ALLOC_BLOCK(ip, nxlen)) { | 144 | if (vfs_dq_alloc_block(ip, nxlen)) { |
145 | dbFree(ip, nxaddr, (s64) nxlen); | 145 | dbFree(ip, nxaddr, (s64) nxlen); |
146 | mutex_unlock(&JFS_IP(ip)->commit_mutex); | 146 | mutex_unlock(&JFS_IP(ip)->commit_mutex); |
147 | return -EDQUOT; | 147 | return -EDQUOT; |
@@ -164,7 +164,7 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr) | |||
164 | */ | 164 | */ |
165 | if (rc) { | 165 | if (rc) { |
166 | dbFree(ip, nxaddr, nxlen); | 166 | dbFree(ip, nxaddr, nxlen); |
167 | DQUOT_FREE_BLOCK(ip, nxlen); | 167 | vfs_dq_free_block(ip, nxlen); |
168 | mutex_unlock(&JFS_IP(ip)->commit_mutex); | 168 | mutex_unlock(&JFS_IP(ip)->commit_mutex); |
169 | return (rc); | 169 | return (rc); |
170 | } | 170 | } |
@@ -256,7 +256,7 @@ int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr) | |||
256 | goto exit; | 256 | goto exit; |
257 | 257 | ||
258 | /* Allocat blocks to quota. */ | 258 | /* Allocat blocks to quota. */ |
259 | if (DQUOT_ALLOC_BLOCK(ip, nxlen)) { | 259 | if (vfs_dq_alloc_block(ip, nxlen)) { |
260 | dbFree(ip, nxaddr, (s64) nxlen); | 260 | dbFree(ip, nxaddr, (s64) nxlen); |
261 | mutex_unlock(&JFS_IP(ip)->commit_mutex); | 261 | mutex_unlock(&JFS_IP(ip)->commit_mutex); |
262 | return -EDQUOT; | 262 | return -EDQUOT; |
@@ -297,7 +297,7 @@ int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr) | |||
297 | /* extend the extent */ | 297 | /* extend the extent */ |
298 | if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) { | 298 | if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) { |
299 | dbFree(ip, xaddr + xlen, delta); | 299 | dbFree(ip, xaddr + xlen, delta); |
300 | DQUOT_FREE_BLOCK(ip, nxlen); | 300 | vfs_dq_free_block(ip, nxlen); |
301 | goto exit; | 301 | goto exit; |
302 | } | 302 | } |
303 | } else { | 303 | } else { |
@@ -308,7 +308,7 @@ int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr) | |||
308 | */ | 308 | */ |
309 | if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) { | 309 | if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) { |
310 | dbFree(ip, nxaddr, nxlen); | 310 | dbFree(ip, nxaddr, nxlen); |
311 | DQUOT_FREE_BLOCK(ip, nxlen); | 311 | vfs_dq_free_block(ip, nxlen); |
312 | goto exit; | 312 | goto exit; |
313 | } | 313 | } |
314 | } | 314 | } |
diff --git a/fs/jfs/jfs_inode.c b/fs/jfs/jfs_inode.c index d4d142c2edd4..dc0e02159ac9 100644 --- a/fs/jfs/jfs_inode.c +++ b/fs/jfs/jfs_inode.c | |||
@@ -116,7 +116,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode) | |||
116 | /* | 116 | /* |
117 | * Allocate inode to quota. | 117 | * Allocate inode to quota. |
118 | */ | 118 | */ |
119 | if (DQUOT_ALLOC_INODE(inode)) { | 119 | if (vfs_dq_alloc_inode(inode)) { |
120 | rc = -EDQUOT; | 120 | rc = -EDQUOT; |
121 | goto fail_drop; | 121 | goto fail_drop; |
122 | } | 122 | } |
@@ -162,7 +162,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode) | |||
162 | return inode; | 162 | return inode; |
163 | 163 | ||
164 | fail_drop: | 164 | fail_drop: |
165 | DQUOT_DROP(inode); | 165 | vfs_dq_drop(inode); |
166 | inode->i_flags |= S_NOQUOTA; | 166 | inode->i_flags |= S_NOQUOTA; |
167 | fail_unlock: | 167 | fail_unlock: |
168 | inode->i_nlink = 0; | 168 | inode->i_nlink = 0; |
diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h index adb2fafcc544..1eff7db34d63 100644 --- a/fs/jfs/jfs_inode.h +++ b/fs/jfs/jfs_inode.h | |||
@@ -47,5 +47,5 @@ extern const struct file_operations jfs_dir_operations; | |||
47 | extern const struct inode_operations jfs_file_inode_operations; | 47 | extern const struct inode_operations jfs_file_inode_operations; |
48 | extern const struct file_operations jfs_file_operations; | 48 | extern const struct file_operations jfs_file_operations; |
49 | extern const struct inode_operations jfs_symlink_inode_operations; | 49 | extern const struct inode_operations jfs_symlink_inode_operations; |
50 | extern struct dentry_operations jfs_ci_dentry_operations; | 50 | extern const struct dentry_operations jfs_ci_dentry_operations; |
51 | #endif /* _H_JFS_INODE */ | 51 | #endif /* _H_JFS_INODE */ |
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c index ae3acafb447b..a27e26c90568 100644 --- a/fs/jfs/jfs_xtree.c +++ b/fs/jfs/jfs_xtree.c | |||
@@ -846,10 +846,10 @@ int xtInsert(tid_t tid, /* transaction id */ | |||
846 | hint = addressXAD(xad) + lengthXAD(xad) - 1; | 846 | hint = addressXAD(xad) + lengthXAD(xad) - 1; |
847 | } else | 847 | } else |
848 | hint = 0; | 848 | hint = 0; |
849 | if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen))) | 849 | if ((rc = vfs_dq_alloc_block(ip, xlen))) |
850 | goto out; | 850 | goto out; |
851 | if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) { | 851 | if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) { |
852 | DQUOT_FREE_BLOCK(ip, xlen); | 852 | vfs_dq_free_block(ip, xlen); |
853 | goto out; | 853 | goto out; |
854 | } | 854 | } |
855 | } | 855 | } |
@@ -878,7 +878,7 @@ int xtInsert(tid_t tid, /* transaction id */ | |||
878 | /* undo data extent allocation */ | 878 | /* undo data extent allocation */ |
879 | if (*xaddrp == 0) { | 879 | if (*xaddrp == 0) { |
880 | dbFree(ip, xaddr, (s64) xlen); | 880 | dbFree(ip, xaddr, (s64) xlen); |
881 | DQUOT_FREE_BLOCK(ip, xlen); | 881 | vfs_dq_free_block(ip, xlen); |
882 | } | 882 | } |
883 | return rc; | 883 | return rc; |
884 | } | 884 | } |
@@ -1246,7 +1246,7 @@ xtSplitPage(tid_t tid, struct inode *ip, | |||
1246 | rbn = addressPXD(pxd); | 1246 | rbn = addressPXD(pxd); |
1247 | 1247 | ||
1248 | /* Allocate blocks to quota. */ | 1248 | /* Allocate blocks to quota. */ |
1249 | if (DQUOT_ALLOC_BLOCK(ip, lengthPXD(pxd))) { | 1249 | if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { |
1250 | rc = -EDQUOT; | 1250 | rc = -EDQUOT; |
1251 | goto clean_up; | 1251 | goto clean_up; |
1252 | } | 1252 | } |
@@ -1456,7 +1456,7 @@ xtSplitPage(tid_t tid, struct inode *ip, | |||
1456 | 1456 | ||
1457 | /* Rollback quota allocation. */ | 1457 | /* Rollback quota allocation. */ |
1458 | if (quota_allocation) | 1458 | if (quota_allocation) |
1459 | DQUOT_FREE_BLOCK(ip, quota_allocation); | 1459 | vfs_dq_free_block(ip, quota_allocation); |
1460 | 1460 | ||
1461 | return (rc); | 1461 | return (rc); |
1462 | } | 1462 | } |
@@ -1513,7 +1513,7 @@ xtSplitRoot(tid_t tid, | |||
1513 | return -EIO; | 1513 | return -EIO; |
1514 | 1514 | ||
1515 | /* Allocate blocks to quota. */ | 1515 | /* Allocate blocks to quota. */ |
1516 | if (DQUOT_ALLOC_BLOCK(ip, lengthPXD(pxd))) { | 1516 | if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { |
1517 | release_metapage(rmp); | 1517 | release_metapage(rmp); |
1518 | return -EDQUOT; | 1518 | return -EDQUOT; |
1519 | } | 1519 | } |
@@ -3941,7 +3941,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) | |||
3941 | ip->i_size = newsize; | 3941 | ip->i_size = newsize; |
3942 | 3942 | ||
3943 | /* update quota allocation to reflect freed blocks */ | 3943 | /* update quota allocation to reflect freed blocks */ |
3944 | DQUOT_FREE_BLOCK(ip, nfreed); | 3944 | vfs_dq_free_block(ip, nfreed); |
3945 | 3945 | ||
3946 | /* | 3946 | /* |
3947 | * free tlock of invalidated pages | 3947 | * free tlock of invalidated pages |
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index b4de56b851e4..514ee2edb92a 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
@@ -35,7 +35,7 @@ | |||
35 | /* | 35 | /* |
36 | * forward references | 36 | * forward references |
37 | */ | 37 | */ |
38 | struct dentry_operations jfs_ci_dentry_operations; | 38 | const struct dentry_operations jfs_ci_dentry_operations; |
39 | 39 | ||
40 | static s64 commitZeroLink(tid_t, struct inode *); | 40 | static s64 commitZeroLink(tid_t, struct inode *); |
41 | 41 | ||
@@ -356,7 +356,7 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry) | |||
356 | jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name); | 356 | jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name); |
357 | 357 | ||
358 | /* Init inode for quota operations. */ | 358 | /* Init inode for quota operations. */ |
359 | DQUOT_INIT(ip); | 359 | vfs_dq_init(ip); |
360 | 360 | ||
361 | /* directory must be empty to be removed */ | 361 | /* directory must be empty to be removed */ |
362 | if (!dtEmpty(ip)) { | 362 | if (!dtEmpty(ip)) { |
@@ -483,7 +483,7 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry) | |||
483 | jfs_info("jfs_unlink: dip:0x%p name:%s", dip, dentry->d_name.name); | 483 | jfs_info("jfs_unlink: dip:0x%p name:%s", dip, dentry->d_name.name); |
484 | 484 | ||
485 | /* Init inode for quota operations. */ | 485 | /* Init inode for quota operations. */ |
486 | DQUOT_INIT(ip); | 486 | vfs_dq_init(ip); |
487 | 487 | ||
488 | if ((rc = get_UCSname(&dname, dentry))) | 488 | if ((rc = get_UCSname(&dname, dentry))) |
489 | goto out; | 489 | goto out; |
@@ -1136,7 +1136,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1136 | } else if (new_ip) { | 1136 | } else if (new_ip) { |
1137 | IWRITE_LOCK(new_ip, RDWRLOCK_NORMAL); | 1137 | IWRITE_LOCK(new_ip, RDWRLOCK_NORMAL); |
1138 | /* Init inode for quota operations. */ | 1138 | /* Init inode for quota operations. */ |
1139 | DQUOT_INIT(new_ip); | 1139 | vfs_dq_init(new_ip); |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | /* | 1142 | /* |
@@ -1595,7 +1595,7 @@ out: | |||
1595 | return result; | 1595 | return result; |
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | struct dentry_operations jfs_ci_dentry_operations = | 1598 | const struct dentry_operations jfs_ci_dentry_operations = |
1599 | { | 1599 | { |
1600 | .d_hash = jfs_ci_hash, | 1600 | .d_hash = jfs_ci_hash, |
1601 | .d_compare = jfs_ci_compare, | 1601 | .d_compare = jfs_ci_compare, |
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index 9b7f2cdaae0a..61dfa8173ebc 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c | |||
@@ -260,14 +260,14 @@ static int ea_write(struct inode *ip, struct jfs_ea_list *ealist, int size, | |||
260 | nblocks = (size + (sb->s_blocksize - 1)) >> sb->s_blocksize_bits; | 260 | nblocks = (size + (sb->s_blocksize - 1)) >> sb->s_blocksize_bits; |
261 | 261 | ||
262 | /* Allocate new blocks to quota. */ | 262 | /* Allocate new blocks to quota. */ |
263 | if (DQUOT_ALLOC_BLOCK(ip, nblocks)) { | 263 | if (vfs_dq_alloc_block(ip, nblocks)) { |
264 | return -EDQUOT; | 264 | return -EDQUOT; |
265 | } | 265 | } |
266 | 266 | ||
267 | rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno); | 267 | rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno); |
268 | if (rc) { | 268 | if (rc) { |
269 | /*Rollback quota allocation. */ | 269 | /*Rollback quota allocation. */ |
270 | DQUOT_FREE_BLOCK(ip, nblocks); | 270 | vfs_dq_free_block(ip, nblocks); |
271 | return rc; | 271 | return rc; |
272 | } | 272 | } |
273 | 273 | ||
@@ -332,7 +332,7 @@ static int ea_write(struct inode *ip, struct jfs_ea_list *ealist, int size, | |||
332 | 332 | ||
333 | failed: | 333 | failed: |
334 | /* Rollback quota allocation. */ | 334 | /* Rollback quota allocation. */ |
335 | DQUOT_FREE_BLOCK(ip, nblocks); | 335 | vfs_dq_free_block(ip, nblocks); |
336 | 336 | ||
337 | dbFree(ip, blkno, nblocks); | 337 | dbFree(ip, blkno, nblocks); |
338 | return rc; | 338 | return rc; |
@@ -538,7 +538,7 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size) | |||
538 | 538 | ||
539 | if (blocks_needed > current_blocks) { | 539 | if (blocks_needed > current_blocks) { |
540 | /* Allocate new blocks to quota. */ | 540 | /* Allocate new blocks to quota. */ |
541 | if (DQUOT_ALLOC_BLOCK(inode, blocks_needed)) | 541 | if (vfs_dq_alloc_block(inode, blocks_needed)) |
542 | return -EDQUOT; | 542 | return -EDQUOT; |
543 | 543 | ||
544 | quota_allocation = blocks_needed; | 544 | quota_allocation = blocks_needed; |
@@ -602,7 +602,7 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size) | |||
602 | clean_up: | 602 | clean_up: |
603 | /* Rollback quota allocation */ | 603 | /* Rollback quota allocation */ |
604 | if (quota_allocation) | 604 | if (quota_allocation) |
605 | DQUOT_FREE_BLOCK(inode, quota_allocation); | 605 | vfs_dq_free_block(inode, quota_allocation); |
606 | 606 | ||
607 | return (rc); | 607 | return (rc); |
608 | } | 608 | } |
@@ -677,7 +677,7 @@ static int ea_put(tid_t tid, struct inode *inode, struct ea_buffer *ea_buf, | |||
677 | 677 | ||
678 | /* If old blocks exist, they must be removed from quota allocation. */ | 678 | /* If old blocks exist, they must be removed from quota allocation. */ |
679 | if (old_blocks) | 679 | if (old_blocks) |
680 | DQUOT_FREE_BLOCK(inode, old_blocks); | 680 | vfs_dq_free_block(inode, old_blocks); |
681 | 681 | ||
682 | inode->i_ctime = CURRENT_TIME; | 682 | inode->i_ctime = CURRENT_TIME; |
683 | 683 | ||
diff --git a/fs/libfs.c b/fs/libfs.c index 49b44099dabb..4910a36f516e 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -44,7 +44,7 @@ static int simple_delete_dentry(struct dentry *dentry) | |||
44 | */ | 44 | */ |
45 | struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | 45 | struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) |
46 | { | 46 | { |
47 | static struct dentry_operations simple_dentry_operations = { | 47 | static const struct dentry_operations simple_dentry_operations = { |
48 | .d_delete = simple_delete_dentry, | 48 | .d_delete = simple_delete_dentry, |
49 | }; | 49 | }; |
50 | 50 | ||
@@ -242,7 +242,8 @@ int get_sb_pseudo(struct file_system_type *fs_type, char *name, | |||
242 | d_instantiate(dentry, root); | 242 | d_instantiate(dentry, root); |
243 | s->s_root = dentry; | 243 | s->s_root = dentry; |
244 | s->s_flags |= MS_ACTIVE; | 244 | s->s_flags |= MS_ACTIVE; |
245 | return simple_set_mnt(mnt, s); | 245 | simple_set_mnt(mnt, s); |
246 | return 0; | ||
246 | 247 | ||
247 | Enomem: | 248 | Enomem: |
248 | up_write(&s->s_umount); | 249 | up_write(&s->s_umount); |
diff --git a/fs/namei.c b/fs/namei.c index 199317642ad6..d040ce11785d 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -1473,7 +1473,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
1473 | error = security_inode_create(dir, dentry, mode); | 1473 | error = security_inode_create(dir, dentry, mode); |
1474 | if (error) | 1474 | if (error) |
1475 | return error; | 1475 | return error; |
1476 | DQUOT_INIT(dir); | 1476 | vfs_dq_init(dir); |
1477 | error = dir->i_op->create(dir, dentry, mode, nd); | 1477 | error = dir->i_op->create(dir, dentry, mode, nd); |
1478 | if (!error) | 1478 | if (!error) |
1479 | fsnotify_create(dir, dentry); | 1479 | fsnotify_create(dir, dentry); |
@@ -1489,24 +1489,22 @@ int may_open(struct path *path, int acc_mode, int flag) | |||
1489 | if (!inode) | 1489 | if (!inode) |
1490 | return -ENOENT; | 1490 | return -ENOENT; |
1491 | 1491 | ||
1492 | if (S_ISLNK(inode->i_mode)) | 1492 | switch (inode->i_mode & S_IFMT) { |
1493 | case S_IFLNK: | ||
1493 | return -ELOOP; | 1494 | return -ELOOP; |
1494 | 1495 | case S_IFDIR: | |
1495 | if (S_ISDIR(inode->i_mode) && (acc_mode & MAY_WRITE)) | 1496 | if (acc_mode & MAY_WRITE) |
1496 | return -EISDIR; | 1497 | return -EISDIR; |
1497 | 1498 | break; | |
1498 | /* | 1499 | case S_IFBLK: |
1499 | * FIFO's, sockets and device files are special: they don't | 1500 | case S_IFCHR: |
1500 | * actually live on the filesystem itself, and as such you | ||
1501 | * can write to them even if the filesystem is read-only. | ||
1502 | */ | ||
1503 | if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { | ||
1504 | flag &= ~O_TRUNC; | ||
1505 | } else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) { | ||
1506 | if (path->mnt->mnt_flags & MNT_NODEV) | 1501 | if (path->mnt->mnt_flags & MNT_NODEV) |
1507 | return -EACCES; | 1502 | return -EACCES; |
1508 | 1503 | /*FALLTHRU*/ | |
1504 | case S_IFIFO: | ||
1505 | case S_IFSOCK: | ||
1509 | flag &= ~O_TRUNC; | 1506 | flag &= ~O_TRUNC; |
1507 | break; | ||
1510 | } | 1508 | } |
1511 | 1509 | ||
1512 | error = inode_permission(inode, acc_mode); | 1510 | error = inode_permission(inode, acc_mode); |
@@ -1552,7 +1550,7 @@ int may_open(struct path *path, int acc_mode, int flag) | |||
1552 | error = security_path_truncate(path, 0, | 1550 | error = security_path_truncate(path, 0, |
1553 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN); | 1551 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN); |
1554 | if (!error) { | 1552 | if (!error) { |
1555 | DQUOT_INIT(inode); | 1553 | vfs_dq_init(inode); |
1556 | 1554 | ||
1557 | error = do_truncate(dentry, 0, | 1555 | error = do_truncate(dentry, 0, |
1558 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN, | 1556 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN, |
@@ -1563,7 +1561,7 @@ int may_open(struct path *path, int acc_mode, int flag) | |||
1563 | return error; | 1561 | return error; |
1564 | } else | 1562 | } else |
1565 | if (flag & FMODE_WRITE) | 1563 | if (flag & FMODE_WRITE) |
1566 | DQUOT_INIT(inode); | 1564 | vfs_dq_init(inode); |
1567 | 1565 | ||
1568 | return 0; | 1566 | return 0; |
1569 | } | 1567 | } |
@@ -1946,7 +1944,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | |||
1946 | if (error) | 1944 | if (error) |
1947 | return error; | 1945 | return error; |
1948 | 1946 | ||
1949 | DQUOT_INIT(dir); | 1947 | vfs_dq_init(dir); |
1950 | error = dir->i_op->mknod(dir, dentry, mode, dev); | 1948 | error = dir->i_op->mknod(dir, dentry, mode, dev); |
1951 | if (!error) | 1949 | if (!error) |
1952 | fsnotify_create(dir, dentry); | 1950 | fsnotify_create(dir, dentry); |
@@ -2045,7 +2043,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
2045 | if (error) | 2043 | if (error) |
2046 | return error; | 2044 | return error; |
2047 | 2045 | ||
2048 | DQUOT_INIT(dir); | 2046 | vfs_dq_init(dir); |
2049 | error = dir->i_op->mkdir(dir, dentry, mode); | 2047 | error = dir->i_op->mkdir(dir, dentry, mode); |
2050 | if (!error) | 2048 | if (!error) |
2051 | fsnotify_mkdir(dir, dentry); | 2049 | fsnotify_mkdir(dir, dentry); |
@@ -2131,7 +2129,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
2131 | if (!dir->i_op->rmdir) | 2129 | if (!dir->i_op->rmdir) |
2132 | return -EPERM; | 2130 | return -EPERM; |
2133 | 2131 | ||
2134 | DQUOT_INIT(dir); | 2132 | vfs_dq_init(dir); |
2135 | 2133 | ||
2136 | mutex_lock(&dentry->d_inode->i_mutex); | 2134 | mutex_lock(&dentry->d_inode->i_mutex); |
2137 | dentry_unhash(dentry); | 2135 | dentry_unhash(dentry); |
@@ -2218,7 +2216,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry) | |||
2218 | if (!dir->i_op->unlink) | 2216 | if (!dir->i_op->unlink) |
2219 | return -EPERM; | 2217 | return -EPERM; |
2220 | 2218 | ||
2221 | DQUOT_INIT(dir); | 2219 | vfs_dq_init(dir); |
2222 | 2220 | ||
2223 | mutex_lock(&dentry->d_inode->i_mutex); | 2221 | mutex_lock(&dentry->d_inode->i_mutex); |
2224 | if (d_mountpoint(dentry)) | 2222 | if (d_mountpoint(dentry)) |
@@ -2329,7 +2327,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname) | |||
2329 | if (error) | 2327 | if (error) |
2330 | return error; | 2328 | return error; |
2331 | 2329 | ||
2332 | DQUOT_INIT(dir); | 2330 | vfs_dq_init(dir); |
2333 | error = dir->i_op->symlink(dir, dentry, oldname); | 2331 | error = dir->i_op->symlink(dir, dentry, oldname); |
2334 | if (!error) | 2332 | if (!error) |
2335 | fsnotify_create(dir, dentry); | 2333 | fsnotify_create(dir, dentry); |
@@ -2413,7 +2411,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de | |||
2413 | return error; | 2411 | return error; |
2414 | 2412 | ||
2415 | mutex_lock(&inode->i_mutex); | 2413 | mutex_lock(&inode->i_mutex); |
2416 | DQUOT_INIT(dir); | 2414 | vfs_dq_init(dir); |
2417 | error = dir->i_op->link(old_dentry, dir, new_dentry); | 2415 | error = dir->i_op->link(old_dentry, dir, new_dentry); |
2418 | mutex_unlock(&inode->i_mutex); | 2416 | mutex_unlock(&inode->i_mutex); |
2419 | if (!error) | 2417 | if (!error) |
@@ -2612,8 +2610,8 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2612 | if (!old_dir->i_op->rename) | 2610 | if (!old_dir->i_op->rename) |
2613 | return -EPERM; | 2611 | return -EPERM; |
2614 | 2612 | ||
2615 | DQUOT_INIT(old_dir); | 2613 | vfs_dq_init(old_dir); |
2616 | DQUOT_INIT(new_dir); | 2614 | vfs_dq_init(new_dir); |
2617 | 2615 | ||
2618 | old_name = fsnotify_oldname_init(old_dentry->d_name.name); | 2616 | old_name = fsnotify_oldname_init(old_dentry->d_name.name); |
2619 | 2617 | ||
diff --git a/fs/namespace.c b/fs/namespace.c index f0e753097353..0a42e0e96027 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -397,11 +397,10 @@ static void __mnt_unmake_readonly(struct vfsmount *mnt) | |||
397 | spin_unlock(&vfsmount_lock); | 397 | spin_unlock(&vfsmount_lock); |
398 | } | 398 | } |
399 | 399 | ||
400 | int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb) | 400 | void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb) |
401 | { | 401 | { |
402 | mnt->mnt_sb = sb; | 402 | mnt->mnt_sb = sb; |
403 | mnt->mnt_root = dget(sb->s_root); | 403 | mnt->mnt_root = dget(sb->s_root); |
404 | return 0; | ||
405 | } | 404 | } |
406 | 405 | ||
407 | EXPORT_SYMBOL(simple_set_mnt); | 406 | EXPORT_SYMBOL(simple_set_mnt); |
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index 07e9715b8658..9c590722d87e 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c | |||
@@ -79,7 +79,7 @@ static int ncp_hash_dentry(struct dentry *, struct qstr *); | |||
79 | static int ncp_compare_dentry (struct dentry *, struct qstr *, struct qstr *); | 79 | static int ncp_compare_dentry (struct dentry *, struct qstr *, struct qstr *); |
80 | static int ncp_delete_dentry(struct dentry *); | 80 | static int ncp_delete_dentry(struct dentry *); |
81 | 81 | ||
82 | static struct dentry_operations ncp_dentry_operations = | 82 | static const struct dentry_operations ncp_dentry_operations = |
83 | { | 83 | { |
84 | .d_revalidate = ncp_lookup_validate, | 84 | .d_revalidate = ncp_lookup_validate, |
85 | .d_hash = ncp_hash_dentry, | 85 | .d_hash = ncp_hash_dentry, |
@@ -87,7 +87,7 @@ static struct dentry_operations ncp_dentry_operations = | |||
87 | .d_delete = ncp_delete_dentry, | 87 | .d_delete = ncp_delete_dentry, |
88 | }; | 88 | }; |
89 | 89 | ||
90 | struct dentry_operations ncp_root_dentry_operations = | 90 | const struct dentry_operations ncp_root_dentry_operations = |
91 | { | 91 | { |
92 | .d_hash = ncp_hash_dentry, | 92 | .d_hash = ncp_hash_dentry, |
93 | .d_compare = ncp_compare_dentry, | 93 | .d_compare = ncp_compare_dentry, |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 672368f865ca..78bf72fc1db3 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -899,7 +899,7 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode) | |||
899 | iput(inode); | 899 | iput(inode); |
900 | } | 900 | } |
901 | 901 | ||
902 | struct dentry_operations nfs_dentry_operations = { | 902 | const struct dentry_operations nfs_dentry_operations = { |
903 | .d_revalidate = nfs_lookup_revalidate, | 903 | .d_revalidate = nfs_lookup_revalidate, |
904 | .d_delete = nfs_dentry_delete, | 904 | .d_delete = nfs_dentry_delete, |
905 | .d_iput = nfs_dentry_iput, | 905 | .d_iput = nfs_dentry_iput, |
@@ -967,7 +967,7 @@ out: | |||
967 | #ifdef CONFIG_NFS_V4 | 967 | #ifdef CONFIG_NFS_V4 |
968 | static int nfs_open_revalidate(struct dentry *, struct nameidata *); | 968 | static int nfs_open_revalidate(struct dentry *, struct nameidata *); |
969 | 969 | ||
970 | struct dentry_operations nfs4_dentry_operations = { | 970 | const struct dentry_operations nfs4_dentry_operations = { |
971 | .d_revalidate = nfs_open_revalidate, | 971 | .d_revalidate = nfs_open_revalidate, |
972 | .d_delete = nfs_dentry_delete, | 972 | .d_delete = nfs_dentry_delete, |
973 | .d_iput = nfs_dentry_iput, | 973 | .d_iput = nfs_dentry_iput, |
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 4e4d33204376..84345deab26f 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -179,7 +179,7 @@ struct nfs4_state_recovery_ops { | |||
179 | int (*recover_lock)(struct nfs4_state *, struct file_lock *); | 179 | int (*recover_lock)(struct nfs4_state *, struct file_lock *); |
180 | }; | 180 | }; |
181 | 181 | ||
182 | extern struct dentry_operations nfs4_dentry_operations; | 182 | extern const struct dentry_operations nfs4_dentry_operations; |
183 | extern const struct inode_operations nfs4_dir_inode_operations; | 183 | extern const struct inode_operations nfs4_dir_inode_operations; |
184 | 184 | ||
185 | /* inode.c */ | 185 | /* inode.c */ |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index c165a6403df0..78376b6c0236 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -356,7 +356,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, | |||
356 | put_write_access(inode); | 356 | put_write_access(inode); |
357 | goto out_nfserr; | 357 | goto out_nfserr; |
358 | } | 358 | } |
359 | DQUOT_INIT(inode); | 359 | vfs_dq_init(inode); |
360 | } | 360 | } |
361 | 361 | ||
362 | /* sanitize the mode change */ | 362 | /* sanitize the mode change */ |
@@ -723,7 +723,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, | |||
723 | else | 723 | else |
724 | flags = O_WRONLY|O_LARGEFILE; | 724 | flags = O_WRONLY|O_LARGEFILE; |
725 | 725 | ||
726 | DQUOT_INIT(inode); | 726 | vfs_dq_init(inode); |
727 | } | 727 | } |
728 | *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_path.mnt), | 728 | *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_path.mnt), |
729 | flags, cred); | 729 | flags, cred); |
diff --git a/fs/notify/inotify/inotify.c b/fs/notify/inotify/inotify.c index 331f2e88e284..220c13f0d73d 100644 --- a/fs/notify/inotify/inotify.c +++ b/fs/notify/inotify/inotify.c | |||
@@ -380,6 +380,14 @@ void inotify_unmount_inodes(struct list_head *list) | |||
380 | struct list_head *watches; | 380 | struct list_head *watches; |
381 | 381 | ||
382 | /* | 382 | /* |
383 | * We cannot __iget() an inode in state I_CLEAR, I_FREEING, | ||
384 | * I_WILL_FREE, or I_NEW which is fine because by that point | ||
385 | * the inode cannot have any associated watches. | ||
386 | */ | ||
387 | if (inode->i_state & (I_CLEAR|I_FREEING|I_WILL_FREE|I_NEW)) | ||
388 | continue; | ||
389 | |||
390 | /* | ||
383 | * If i_count is zero, the inode cannot have any watches and | 391 | * If i_count is zero, the inode cannot have any watches and |
384 | * doing an __iget/iput with MS_ACTIVE clear would actually | 392 | * doing an __iget/iput with MS_ACTIVE clear would actually |
385 | * evict all inodes with zero i_count from icache which is | 393 | * evict all inodes with zero i_count from icache which is |
@@ -388,14 +396,6 @@ void inotify_unmount_inodes(struct list_head *list) | |||
388 | if (!atomic_read(&inode->i_count)) | 396 | if (!atomic_read(&inode->i_count)) |
389 | continue; | 397 | continue; |
390 | 398 | ||
391 | /* | ||
392 | * We cannot __iget() an inode in state I_CLEAR, I_FREEING, or | ||
393 | * I_WILL_FREE which is fine because by that point the inode | ||
394 | * cannot have any associated watches. | ||
395 | */ | ||
396 | if (inode->i_state & (I_CLEAR | I_FREEING | I_WILL_FREE)) | ||
397 | continue; | ||
398 | |||
399 | need_iput_tmp = need_iput; | 399 | need_iput_tmp = need_iput; |
400 | need_iput = NULL; | 400 | need_iput = NULL; |
401 | /* In case inotify_remove_watch_locked() drops a reference. */ | 401 | /* In case inotify_remove_watch_locked() drops a reference. */ |
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c index e9d7c2038c0f..7d604480557a 100644 --- a/fs/ocfs2/dcache.c +++ b/fs/ocfs2/dcache.c | |||
@@ -455,7 +455,7 @@ out_move: | |||
455 | d_move(dentry, target); | 455 | d_move(dentry, target); |
456 | } | 456 | } |
457 | 457 | ||
458 | struct dentry_operations ocfs2_dentry_ops = { | 458 | const struct dentry_operations ocfs2_dentry_ops = { |
459 | .d_revalidate = ocfs2_dentry_revalidate, | 459 | .d_revalidate = ocfs2_dentry_revalidate, |
460 | .d_iput = ocfs2_dentry_iput, | 460 | .d_iput = ocfs2_dentry_iput, |
461 | }; | 461 | }; |
diff --git a/fs/ocfs2/dcache.h b/fs/ocfs2/dcache.h index d06e16c06640..faa12e75f98d 100644 --- a/fs/ocfs2/dcache.h +++ b/fs/ocfs2/dcache.h | |||
@@ -26,7 +26,7 @@ | |||
26 | #ifndef OCFS2_DCACHE_H | 26 | #ifndef OCFS2_DCACHE_H |
27 | #define OCFS2_DCACHE_H | 27 | #define OCFS2_DCACHE_H |
28 | 28 | ||
29 | extern struct dentry_operations ocfs2_dentry_ops; | 29 | extern const struct dentry_operations ocfs2_dentry_ops; |
30 | 30 | ||
31 | struct ocfs2_dentry_lock { | 31 | struct ocfs2_dentry_lock { |
32 | /* Use count of dentry lock */ | 32 | /* Use count of dentry lock */ |
@@ -273,7 +273,7 @@ static long do_sys_truncate(const char __user *pathname, loff_t length) | |||
273 | if (!error) | 273 | if (!error) |
274 | error = security_path_truncate(&path, length, 0); | 274 | error = security_path_truncate(&path, length, 0); |
275 | if (!error) { | 275 | if (!error) { |
276 | DQUOT_INIT(inode); | 276 | vfs_dq_init(inode); |
277 | error = do_truncate(path.dentry, length, 0, NULL); | 277 | error = do_truncate(path.dentry, length, 0, NULL); |
278 | } | 278 | } |
279 | 279 | ||
@@ -860,7 +860,7 @@ static char *pipefs_dname(struct dentry *dentry, char *buffer, int buflen) | |||
860 | dentry->d_inode->i_ino); | 860 | dentry->d_inode->i_ino); |
861 | } | 861 | } |
862 | 862 | ||
863 | static struct dentry_operations pipefs_dentry_operations = { | 863 | static const struct dentry_operations pipefs_dentry_operations = { |
864 | .d_delete = pipefs_delete_dentry, | 864 | .d_delete = pipefs_delete_dentry, |
865 | .d_dname = pipefs_dname, | 865 | .d_dname = pipefs_dname, |
866 | }; | 866 | }; |
@@ -1024,11 +1024,6 @@ int do_pipe_flags(int *fd, int flags) | |||
1024 | return error; | 1024 | return error; |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | int do_pipe(int *fd) | ||
1028 | { | ||
1029 | return do_pipe_flags(fd, 0); | ||
1030 | } | ||
1031 | |||
1032 | /* | 1027 | /* |
1033 | * sys_pipe() is the normal C calling standard for creating | 1028 | * sys_pipe() is the normal C calling standard for creating |
1034 | * a pipe. It's not the way Unix traditionally does this, though. | 1029 | * a pipe. It's not the way Unix traditionally does this, though. |
diff --git a/fs/proc/base.c b/fs/proc/base.c index beaa0ce3b82e..aef6d55b7de6 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -1545,7 +1545,7 @@ static int pid_delete_dentry(struct dentry * dentry) | |||
1545 | return !proc_pid(dentry->d_inode)->tasks[PIDTYPE_PID].first; | 1545 | return !proc_pid(dentry->d_inode)->tasks[PIDTYPE_PID].first; |
1546 | } | 1546 | } |
1547 | 1547 | ||
1548 | static struct dentry_operations pid_dentry_operations = | 1548 | static const struct dentry_operations pid_dentry_operations = |
1549 | { | 1549 | { |
1550 | .d_revalidate = pid_revalidate, | 1550 | .d_revalidate = pid_revalidate, |
1551 | .d_delete = pid_delete_dentry, | 1551 | .d_delete = pid_delete_dentry, |
@@ -1717,7 +1717,7 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1717 | return 0; | 1717 | return 0; |
1718 | } | 1718 | } |
1719 | 1719 | ||
1720 | static struct dentry_operations tid_fd_dentry_operations = | 1720 | static const struct dentry_operations tid_fd_dentry_operations = |
1721 | { | 1721 | { |
1722 | .d_revalidate = tid_fd_revalidate, | 1722 | .d_revalidate = tid_fd_revalidate, |
1723 | .d_delete = pid_delete_dentry, | 1723 | .d_delete = pid_delete_dentry, |
@@ -2339,7 +2339,7 @@ static int proc_base_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
2339 | return 0; | 2339 | return 0; |
2340 | } | 2340 | } |
2341 | 2341 | ||
2342 | static struct dentry_operations proc_base_dentry_operations = | 2342 | static const struct dentry_operations proc_base_dentry_operations = |
2343 | { | 2343 | { |
2344 | .d_revalidate = proc_base_revalidate, | 2344 | .d_revalidate = proc_base_revalidate, |
2345 | .d_delete = pid_delete_dentry, | 2345 | .d_delete = pid_delete_dentry, |
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index db7fa5cab988..5d2989e9dcc1 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -363,7 +363,7 @@ static int proc_delete_dentry(struct dentry * dentry) | |||
363 | return 1; | 363 | return 1; |
364 | } | 364 | } |
365 | 365 | ||
366 | static struct dentry_operations proc_dentry_operations = | 366 | static const struct dentry_operations proc_dentry_operations = |
367 | { | 367 | { |
368 | .d_delete = proc_delete_dentry, | 368 | .d_delete = proc_delete_dentry, |
369 | }; | 369 | }; |
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 94fcfff6863a..9b1e4e9a16bf 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -7,7 +7,7 @@ | |||
7 | #include <linux/security.h> | 7 | #include <linux/security.h> |
8 | #include "internal.h" | 8 | #include "internal.h" |
9 | 9 | ||
10 | static struct dentry_operations proc_sys_dentry_operations; | 10 | static const struct dentry_operations proc_sys_dentry_operations; |
11 | static const struct file_operations proc_sys_file_operations; | 11 | static const struct file_operations proc_sys_file_operations; |
12 | static const struct inode_operations proc_sys_inode_operations; | 12 | static const struct inode_operations proc_sys_inode_operations; |
13 | static const struct file_operations proc_sys_dir_file_operations; | 13 | static const struct file_operations proc_sys_dir_file_operations; |
@@ -396,7 +396,7 @@ static int proc_sys_compare(struct dentry *dir, struct qstr *qstr, | |||
396 | return !sysctl_is_seen(PROC_I(dentry->d_inode)->sysctl); | 396 | return !sysctl_is_seen(PROC_I(dentry->d_inode)->sysctl); |
397 | } | 397 | } |
398 | 398 | ||
399 | static struct dentry_operations proc_sys_dentry_operations = { | 399 | static const struct dentry_operations proc_sys_dentry_operations = { |
400 | .d_revalidate = proc_sys_revalidate, | 400 | .d_revalidate = proc_sys_revalidate, |
401 | .d_delete = proc_sys_delete, | 401 | .d_delete = proc_sys_delete, |
402 | .d_compare = proc_sys_compare, | 402 | .d_compare = proc_sys_compare, |
diff --git a/fs/proc/root.c b/fs/proc/root.c index f6299a25594e..1e15a2b176e8 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c | |||
@@ -83,7 +83,8 @@ static int proc_get_sb(struct file_system_type *fs_type, | |||
83 | ns->proc_mnt = mnt; | 83 | ns->proc_mnt = mnt; |
84 | } | 84 | } |
85 | 85 | ||
86 | return simple_set_mnt(mnt, sb); | 86 | simple_set_mnt(mnt, sb); |
87 | return 0; | ||
87 | } | 88 | } |
88 | 89 | ||
89 | static void proc_kill_sb(struct super_block *sb) | 90 | static void proc_kill_sb(struct super_block *sb) |
diff --git a/fs/quota/Kconfig b/fs/quota/Kconfig new file mode 100644 index 000000000000..8047e01ef46b --- /dev/null +++ b/fs/quota/Kconfig | |||
@@ -0,0 +1,59 @@ | |||
1 | # | ||
2 | # Quota configuration | ||
3 | # | ||
4 | |||
5 | config QUOTA | ||
6 | bool "Quota support" | ||
7 | help | ||
8 | If you say Y here, you will be able to set per user limits for disk | ||
9 | usage (also called disk quotas). Currently, it works for the | ||
10 | ext2, ext3, and reiserfs file system. ext3 also supports journalled | ||
11 | quotas for which you don't need to run quotacheck(8) after an unclean | ||
12 | shutdown. | ||
13 | For further details, read the Quota mini-HOWTO, available from | ||
14 | <http://www.tldp.org/docs.html#howto>, or the documentation provided | ||
15 | with the quota tools. Probably the quota support is only useful for | ||
16 | multi user systems. If unsure, say N. | ||
17 | |||
18 | config QUOTA_NETLINK_INTERFACE | ||
19 | bool "Report quota messages through netlink interface" | ||
20 | depends on QUOTA && NET | ||
21 | help | ||
22 | If you say Y here, quota warnings (about exceeding softlimit, reaching | ||
23 | hardlimit, etc.) will be reported through netlink interface. If unsure, | ||
24 | say Y. | ||
25 | |||
26 | config PRINT_QUOTA_WARNING | ||
27 | bool "Print quota warnings to console (OBSOLETE)" | ||
28 | depends on QUOTA | ||
29 | default y | ||
30 | help | ||
31 | If you say Y here, quota warnings (about exceeding softlimit, reaching | ||
32 | hardlimit, etc.) will be printed to the process' controlling terminal. | ||
33 | Note that this behavior is currently deprecated and may go away in | ||
34 | future. Please use notification via netlink socket instead. | ||
35 | |||
36 | # Generic support for tree structured quota files. Selected when needed. | ||
37 | config QUOTA_TREE | ||
38 | tristate | ||
39 | |||
40 | config QFMT_V1 | ||
41 | tristate "Old quota format support" | ||
42 | depends on QUOTA | ||
43 | help | ||
44 | This quota format was (is) used by kernels earlier than 2.4.22. If | ||
45 | you have quota working and you don't want to convert to new quota | ||
46 | format say Y here. | ||
47 | |||
48 | config QFMT_V2 | ||
49 | tristate "Quota format v2 support" | ||
50 | depends on QUOTA | ||
51 | select QUOTA_TREE | ||
52 | help | ||
53 | This quota format allows using quotas with 32-bit UIDs/GIDs. If you | ||
54 | need this functionality say Y here. | ||
55 | |||
56 | config QUOTACTL | ||
57 | bool | ||
58 | depends on XFS_QUOTA || QUOTA | ||
59 | default y | ||
diff --git a/fs/quota/Makefile b/fs/quota/Makefile new file mode 100644 index 000000000000..385a0831cc99 --- /dev/null +++ b/fs/quota/Makefile | |||
@@ -0,0 +1,14 @@ | |||
1 | # | ||
2 | # Makefile for the Linux filesystems. | ||
3 | # | ||
4 | # 14 Sep 2000, Christoph Hellwig <hch@infradead.org> | ||
5 | # Rewritten to use lists instead of if-statements. | ||
6 | # | ||
7 | |||
8 | obj-y := | ||
9 | |||
10 | obj-$(CONFIG_QUOTA) += dquot.o | ||
11 | obj-$(CONFIG_QFMT_V1) += quota_v1.o | ||
12 | obj-$(CONFIG_QFMT_V2) += quota_v2.o | ||
13 | obj-$(CONFIG_QUOTA_TREE) += quota_tree.o | ||
14 | obj-$(CONFIG_QUOTACTL) += quota.o | ||
diff --git a/fs/dquot.c b/fs/quota/dquot.c index d6add0bf5ad3..2ca967a5ef77 100644 --- a/fs/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -129,9 +129,10 @@ | |||
129 | * i_mutex on quota files is special (it's below dqio_mutex) | 129 | * i_mutex on quota files is special (it's below dqio_mutex) |
130 | */ | 130 | */ |
131 | 131 | ||
132 | static DEFINE_SPINLOCK(dq_list_lock); | 132 | static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_list_lock); |
133 | static DEFINE_SPINLOCK(dq_state_lock); | 133 | static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_state_lock); |
134 | DEFINE_SPINLOCK(dq_data_lock); | 134 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_data_lock); |
135 | EXPORT_SYMBOL(dq_data_lock); | ||
135 | 136 | ||
136 | static char *quotatypes[] = INITQFNAMES; | 137 | static char *quotatypes[] = INITQFNAMES; |
137 | static struct quota_format_type *quota_formats; /* List of registered formats */ | 138 | static struct quota_format_type *quota_formats; /* List of registered formats */ |
@@ -148,35 +149,46 @@ int register_quota_format(struct quota_format_type *fmt) | |||
148 | spin_unlock(&dq_list_lock); | 149 | spin_unlock(&dq_list_lock); |
149 | return 0; | 150 | return 0; |
150 | } | 151 | } |
152 | EXPORT_SYMBOL(register_quota_format); | ||
151 | 153 | ||
152 | void unregister_quota_format(struct quota_format_type *fmt) | 154 | void unregister_quota_format(struct quota_format_type *fmt) |
153 | { | 155 | { |
154 | struct quota_format_type **actqf; | 156 | struct quota_format_type **actqf; |
155 | 157 | ||
156 | spin_lock(&dq_list_lock); | 158 | spin_lock(&dq_list_lock); |
157 | for (actqf = "a_formats; *actqf && *actqf != fmt; actqf = &(*actqf)->qf_next); | 159 | for (actqf = "a_formats; *actqf && *actqf != fmt; |
160 | actqf = &(*actqf)->qf_next) | ||
161 | ; | ||
158 | if (*actqf) | 162 | if (*actqf) |
159 | *actqf = (*actqf)->qf_next; | 163 | *actqf = (*actqf)->qf_next; |
160 | spin_unlock(&dq_list_lock); | 164 | spin_unlock(&dq_list_lock); |
161 | } | 165 | } |
166 | EXPORT_SYMBOL(unregister_quota_format); | ||
162 | 167 | ||
163 | static struct quota_format_type *find_quota_format(int id) | 168 | static struct quota_format_type *find_quota_format(int id) |
164 | { | 169 | { |
165 | struct quota_format_type *actqf; | 170 | struct quota_format_type *actqf; |
166 | 171 | ||
167 | spin_lock(&dq_list_lock); | 172 | spin_lock(&dq_list_lock); |
168 | for (actqf = quota_formats; actqf && actqf->qf_fmt_id != id; actqf = actqf->qf_next); | 173 | for (actqf = quota_formats; actqf && actqf->qf_fmt_id != id; |
174 | actqf = actqf->qf_next) | ||
175 | ; | ||
169 | if (!actqf || !try_module_get(actqf->qf_owner)) { | 176 | if (!actqf || !try_module_get(actqf->qf_owner)) { |
170 | int qm; | 177 | int qm; |
171 | 178 | ||
172 | spin_unlock(&dq_list_lock); | 179 | spin_unlock(&dq_list_lock); |
173 | 180 | ||
174 | for (qm = 0; module_names[qm].qm_fmt_id && module_names[qm].qm_fmt_id != id; qm++); | 181 | for (qm = 0; module_names[qm].qm_fmt_id && |
175 | if (!module_names[qm].qm_fmt_id || request_module(module_names[qm].qm_mod_name)) | 182 | module_names[qm].qm_fmt_id != id; qm++) |
183 | ; | ||
184 | if (!module_names[qm].qm_fmt_id || | ||
185 | request_module(module_names[qm].qm_mod_name)) | ||
176 | return NULL; | 186 | return NULL; |
177 | 187 | ||
178 | spin_lock(&dq_list_lock); | 188 | spin_lock(&dq_list_lock); |
179 | for (actqf = quota_formats; actqf && actqf->qf_fmt_id != id; actqf = actqf->qf_next); | 189 | for (actqf = quota_formats; actqf && actqf->qf_fmt_id != id; |
190 | actqf = actqf->qf_next) | ||
191 | ; | ||
180 | if (actqf && !try_module_get(actqf->qf_owner)) | 192 | if (actqf && !try_module_get(actqf->qf_owner)) |
181 | actqf = NULL; | 193 | actqf = NULL; |
182 | } | 194 | } |
@@ -215,6 +227,7 @@ static unsigned int dq_hash_bits, dq_hash_mask; | |||
215 | static struct hlist_head *dquot_hash; | 227 | static struct hlist_head *dquot_hash; |
216 | 228 | ||
217 | struct dqstats dqstats; | 229 | struct dqstats dqstats; |
230 | EXPORT_SYMBOL(dqstats); | ||
218 | 231 | ||
219 | static inline unsigned int | 232 | static inline unsigned int |
220 | hashfn(const struct super_block *sb, unsigned int id, int type) | 233 | hashfn(const struct super_block *sb, unsigned int id, int type) |
@@ -230,7 +243,8 @@ hashfn(const struct super_block *sb, unsigned int id, int type) | |||
230 | */ | 243 | */ |
231 | static inline void insert_dquot_hash(struct dquot *dquot) | 244 | static inline void insert_dquot_hash(struct dquot *dquot) |
232 | { | 245 | { |
233 | struct hlist_head *head = dquot_hash + hashfn(dquot->dq_sb, dquot->dq_id, dquot->dq_type); | 246 | struct hlist_head *head; |
247 | head = dquot_hash + hashfn(dquot->dq_sb, dquot->dq_id, dquot->dq_type); | ||
234 | hlist_add_head(&dquot->dq_hash, head); | 248 | hlist_add_head(&dquot->dq_hash, head); |
235 | } | 249 | } |
236 | 250 | ||
@@ -239,17 +253,19 @@ static inline void remove_dquot_hash(struct dquot *dquot) | |||
239 | hlist_del_init(&dquot->dq_hash); | 253 | hlist_del_init(&dquot->dq_hash); |
240 | } | 254 | } |
241 | 255 | ||
242 | static inline struct dquot *find_dquot(unsigned int hashent, struct super_block *sb, unsigned int id, int type) | 256 | static struct dquot *find_dquot(unsigned int hashent, struct super_block *sb, |
257 | unsigned int id, int type) | ||
243 | { | 258 | { |
244 | struct hlist_node *node; | 259 | struct hlist_node *node; |
245 | struct dquot *dquot; | 260 | struct dquot *dquot; |
246 | 261 | ||
247 | hlist_for_each (node, dquot_hash+hashent) { | 262 | hlist_for_each (node, dquot_hash+hashent) { |
248 | dquot = hlist_entry(node, struct dquot, dq_hash); | 263 | dquot = hlist_entry(node, struct dquot, dq_hash); |
249 | if (dquot->dq_sb == sb && dquot->dq_id == id && dquot->dq_type == type) | 264 | if (dquot->dq_sb == sb && dquot->dq_id == id && |
265 | dquot->dq_type == type) | ||
250 | return dquot; | 266 | return dquot; |
251 | } | 267 | } |
252 | return NODQUOT; | 268 | return NULL; |
253 | } | 269 | } |
254 | 270 | ||
255 | /* Add a dquot to the tail of the free list */ | 271 | /* Add a dquot to the tail of the free list */ |
@@ -309,6 +325,7 @@ int dquot_mark_dquot_dirty(struct dquot *dquot) | |||
309 | spin_unlock(&dq_list_lock); | 325 | spin_unlock(&dq_list_lock); |
310 | return 0; | 326 | return 0; |
311 | } | 327 | } |
328 | EXPORT_SYMBOL(dquot_mark_dquot_dirty); | ||
312 | 329 | ||
313 | /* This function needs dq_list_lock */ | 330 | /* This function needs dq_list_lock */ |
314 | static inline int clear_dquot_dirty(struct dquot *dquot) | 331 | static inline int clear_dquot_dirty(struct dquot *dquot) |
@@ -345,8 +362,10 @@ int dquot_acquire(struct dquot *dquot) | |||
345 | if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) { | 362 | if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) { |
346 | ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot); | 363 | ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot); |
347 | /* Write the info if needed */ | 364 | /* Write the info if needed */ |
348 | if (info_dirty(&dqopt->info[dquot->dq_type])) | 365 | if (info_dirty(&dqopt->info[dquot->dq_type])) { |
349 | ret2 = dqopt->ops[dquot->dq_type]->write_file_info(dquot->dq_sb, dquot->dq_type); | 366 | ret2 = dqopt->ops[dquot->dq_type]->write_file_info( |
367 | dquot->dq_sb, dquot->dq_type); | ||
368 | } | ||
350 | if (ret < 0) | 369 | if (ret < 0) |
351 | goto out_iolock; | 370 | goto out_iolock; |
352 | if (ret2 < 0) { | 371 | if (ret2 < 0) { |
@@ -360,6 +379,7 @@ out_iolock: | |||
360 | mutex_unlock(&dquot->dq_lock); | 379 | mutex_unlock(&dquot->dq_lock); |
361 | return ret; | 380 | return ret; |
362 | } | 381 | } |
382 | EXPORT_SYMBOL(dquot_acquire); | ||
363 | 383 | ||
364 | /* | 384 | /* |
365 | * Write dquot to disk | 385 | * Write dquot to disk |
@@ -380,8 +400,10 @@ int dquot_commit(struct dquot *dquot) | |||
380 | * => we have better not writing it */ | 400 | * => we have better not writing it */ |
381 | if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { | 401 | if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { |
382 | ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot); | 402 | ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot); |
383 | if (info_dirty(&dqopt->info[dquot->dq_type])) | 403 | if (info_dirty(&dqopt->info[dquot->dq_type])) { |
384 | ret2 = dqopt->ops[dquot->dq_type]->write_file_info(dquot->dq_sb, dquot->dq_type); | 404 | ret2 = dqopt->ops[dquot->dq_type]->write_file_info( |
405 | dquot->dq_sb, dquot->dq_type); | ||
406 | } | ||
385 | if (ret >= 0) | 407 | if (ret >= 0) |
386 | ret = ret2; | 408 | ret = ret2; |
387 | } | 409 | } |
@@ -389,6 +411,7 @@ out_sem: | |||
389 | mutex_unlock(&dqopt->dqio_mutex); | 411 | mutex_unlock(&dqopt->dqio_mutex); |
390 | return ret; | 412 | return ret; |
391 | } | 413 | } |
414 | EXPORT_SYMBOL(dquot_commit); | ||
392 | 415 | ||
393 | /* | 416 | /* |
394 | * Release dquot | 417 | * Release dquot |
@@ -406,8 +429,10 @@ int dquot_release(struct dquot *dquot) | |||
406 | if (dqopt->ops[dquot->dq_type]->release_dqblk) { | 429 | if (dqopt->ops[dquot->dq_type]->release_dqblk) { |
407 | ret = dqopt->ops[dquot->dq_type]->release_dqblk(dquot); | 430 | ret = dqopt->ops[dquot->dq_type]->release_dqblk(dquot); |
408 | /* Write the info */ | 431 | /* Write the info */ |
409 | if (info_dirty(&dqopt->info[dquot->dq_type])) | 432 | if (info_dirty(&dqopt->info[dquot->dq_type])) { |
410 | ret2 = dqopt->ops[dquot->dq_type]->write_file_info(dquot->dq_sb, dquot->dq_type); | 433 | ret2 = dqopt->ops[dquot->dq_type]->write_file_info( |
434 | dquot->dq_sb, dquot->dq_type); | ||
435 | } | ||
411 | if (ret >= 0) | 436 | if (ret >= 0) |
412 | ret = ret2; | 437 | ret = ret2; |
413 | } | 438 | } |
@@ -417,6 +442,7 @@ out_dqlock: | |||
417 | mutex_unlock(&dquot->dq_lock); | 442 | mutex_unlock(&dquot->dq_lock); |
418 | return ret; | 443 | return ret; |
419 | } | 444 | } |
445 | EXPORT_SYMBOL(dquot_release); | ||
420 | 446 | ||
421 | void dquot_destroy(struct dquot *dquot) | 447 | void dquot_destroy(struct dquot *dquot) |
422 | { | 448 | { |
@@ -516,6 +542,7 @@ out: | |||
516 | mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); | 542 | mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); |
517 | return ret; | 543 | return ret; |
518 | } | 544 | } |
545 | EXPORT_SYMBOL(dquot_scan_active); | ||
519 | 546 | ||
520 | int vfs_quota_sync(struct super_block *sb, int type) | 547 | int vfs_quota_sync(struct super_block *sb, int type) |
521 | { | 548 | { |
@@ -533,7 +560,8 @@ int vfs_quota_sync(struct super_block *sb, int type) | |||
533 | spin_lock(&dq_list_lock); | 560 | spin_lock(&dq_list_lock); |
534 | dirty = &dqopt->info[cnt].dqi_dirty_list; | 561 | dirty = &dqopt->info[cnt].dqi_dirty_list; |
535 | while (!list_empty(dirty)) { | 562 | while (!list_empty(dirty)) { |
536 | dquot = list_first_entry(dirty, struct dquot, dq_dirty); | 563 | dquot = list_first_entry(dirty, struct dquot, |
564 | dq_dirty); | ||
537 | /* Dirty and inactive can be only bad dquot... */ | 565 | /* Dirty and inactive can be only bad dquot... */ |
538 | if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { | 566 | if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { |
539 | clear_dquot_dirty(dquot); | 567 | clear_dquot_dirty(dquot); |
@@ -563,6 +591,7 @@ int vfs_quota_sync(struct super_block *sb, int type) | |||
563 | 591 | ||
564 | return 0; | 592 | return 0; |
565 | } | 593 | } |
594 | EXPORT_SYMBOL(vfs_quota_sync); | ||
566 | 595 | ||
567 | /* Free unused dquots from cache */ | 596 | /* Free unused dquots from cache */ |
568 | static void prune_dqcache(int count) | 597 | static void prune_dqcache(int count) |
@@ -672,6 +701,7 @@ we_slept: | |||
672 | put_dquot_last(dquot); | 701 | put_dquot_last(dquot); |
673 | spin_unlock(&dq_list_lock); | 702 | spin_unlock(&dq_list_lock); |
674 | } | 703 | } |
704 | EXPORT_SYMBOL(dqput); | ||
675 | 705 | ||
676 | struct dquot *dquot_alloc(struct super_block *sb, int type) | 706 | struct dquot *dquot_alloc(struct super_block *sb, int type) |
677 | { | 707 | { |
@@ -685,7 +715,7 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type) | |||
685 | 715 | ||
686 | dquot = sb->dq_op->alloc_dquot(sb, type); | 716 | dquot = sb->dq_op->alloc_dquot(sb, type); |
687 | if(!dquot) | 717 | if(!dquot) |
688 | return NODQUOT; | 718 | return NULL; |
689 | 719 | ||
690 | mutex_init(&dquot->dq_lock); | 720 | mutex_init(&dquot->dq_lock); |
691 | INIT_LIST_HEAD(&dquot->dq_free); | 721 | INIT_LIST_HEAD(&dquot->dq_free); |
@@ -711,10 +741,10 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type) | |||
711 | struct dquot *dqget(struct super_block *sb, unsigned int id, int type) | 741 | struct dquot *dqget(struct super_block *sb, unsigned int id, int type) |
712 | { | 742 | { |
713 | unsigned int hashent = hashfn(sb, id, type); | 743 | unsigned int hashent = hashfn(sb, id, type); |
714 | struct dquot *dquot = NODQUOT, *empty = NODQUOT; | 744 | struct dquot *dquot = NULL, *empty = NULL; |
715 | 745 | ||
716 | if (!sb_has_quota_active(sb, type)) | 746 | if (!sb_has_quota_active(sb, type)) |
717 | return NODQUOT; | 747 | return NULL; |
718 | we_slept: | 748 | we_slept: |
719 | spin_lock(&dq_list_lock); | 749 | spin_lock(&dq_list_lock); |
720 | spin_lock(&dq_state_lock); | 750 | spin_lock(&dq_state_lock); |
@@ -725,15 +755,17 @@ we_slept: | |||
725 | } | 755 | } |
726 | spin_unlock(&dq_state_lock); | 756 | spin_unlock(&dq_state_lock); |
727 | 757 | ||
728 | if ((dquot = find_dquot(hashent, sb, id, type)) == NODQUOT) { | 758 | dquot = find_dquot(hashent, sb, id, type); |
729 | if (empty == NODQUOT) { | 759 | if (!dquot) { |
760 | if (!empty) { | ||
730 | spin_unlock(&dq_list_lock); | 761 | spin_unlock(&dq_list_lock); |
731 | if ((empty = get_empty_dquot(sb, type)) == NODQUOT) | 762 | empty = get_empty_dquot(sb, type); |
763 | if (!empty) | ||
732 | schedule(); /* Try to wait for a moment... */ | 764 | schedule(); /* Try to wait for a moment... */ |
733 | goto we_slept; | 765 | goto we_slept; |
734 | } | 766 | } |
735 | dquot = empty; | 767 | dquot = empty; |
736 | empty = NODQUOT; | 768 | empty = NULL; |
737 | dquot->dq_id = id; | 769 | dquot->dq_id = id; |
738 | /* all dquots go on the inuse_list */ | 770 | /* all dquots go on the inuse_list */ |
739 | put_inuse(dquot); | 771 | put_inuse(dquot); |
@@ -749,13 +781,14 @@ we_slept: | |||
749 | dqstats.lookups++; | 781 | dqstats.lookups++; |
750 | spin_unlock(&dq_list_lock); | 782 | spin_unlock(&dq_list_lock); |
751 | } | 783 | } |
752 | /* Wait for dq_lock - after this we know that either dquot_release() is already | 784 | /* Wait for dq_lock - after this we know that either dquot_release() is |
753 | * finished or it will be canceled due to dq_count > 1 test */ | 785 | * already finished or it will be canceled due to dq_count > 1 test */ |
754 | wait_on_dquot(dquot); | 786 | wait_on_dquot(dquot); |
755 | /* Read the dquot and instantiate it (everything done only if needed) */ | 787 | /* Read the dquot / allocate space in quota file */ |
756 | if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && sb->dq_op->acquire_dquot(dquot) < 0) { | 788 | if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && |
789 | sb->dq_op->acquire_dquot(dquot) < 0) { | ||
757 | dqput(dquot); | 790 | dqput(dquot); |
758 | dquot = NODQUOT; | 791 | dquot = NULL; |
759 | goto out; | 792 | goto out; |
760 | } | 793 | } |
761 | #ifdef __DQUOT_PARANOIA | 794 | #ifdef __DQUOT_PARANOIA |
@@ -767,6 +800,7 @@ out: | |||
767 | 800 | ||
768 | return dquot; | 801 | return dquot; |
769 | } | 802 | } |
803 | EXPORT_SYMBOL(dqget); | ||
770 | 804 | ||
771 | static int dqinit_needed(struct inode *inode, int type) | 805 | static int dqinit_needed(struct inode *inode, int type) |
772 | { | 806 | { |
@@ -775,9 +809,9 @@ static int dqinit_needed(struct inode *inode, int type) | |||
775 | if (IS_NOQUOTA(inode)) | 809 | if (IS_NOQUOTA(inode)) |
776 | return 0; | 810 | return 0; |
777 | if (type != -1) | 811 | if (type != -1) |
778 | return inode->i_dquot[type] == NODQUOT; | 812 | return !inode->i_dquot[type]; |
779 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | 813 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) |
780 | if (inode->i_dquot[cnt] == NODQUOT) | 814 | if (!inode->i_dquot[cnt]) |
781 | return 1; | 815 | return 1; |
782 | return 0; | 816 | return 0; |
783 | } | 817 | } |
@@ -789,12 +823,12 @@ static void add_dquot_ref(struct super_block *sb, int type) | |||
789 | 823 | ||
790 | spin_lock(&inode_lock); | 824 | spin_lock(&inode_lock); |
791 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 825 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
826 | if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) | ||
827 | continue; | ||
792 | if (!atomic_read(&inode->i_writecount)) | 828 | if (!atomic_read(&inode->i_writecount)) |
793 | continue; | 829 | continue; |
794 | if (!dqinit_needed(inode, type)) | 830 | if (!dqinit_needed(inode, type)) |
795 | continue; | 831 | continue; |
796 | if (inode->i_state & (I_FREEING|I_WILL_FREE)) | ||
797 | continue; | ||
798 | 832 | ||
799 | __iget(inode); | 833 | __iget(inode); |
800 | spin_unlock(&inode_lock); | 834 | spin_unlock(&inode_lock); |
@@ -813,7 +847,10 @@ static void add_dquot_ref(struct super_block *sb, int type) | |||
813 | iput(old_inode); | 847 | iput(old_inode); |
814 | } | 848 | } |
815 | 849 | ||
816 | /* Return 0 if dqput() won't block (note that 1 doesn't necessarily mean blocking) */ | 850 | /* |
851 | * Return 0 if dqput() won't block. | ||
852 | * (note that 1 doesn't necessarily mean blocking) | ||
853 | */ | ||
817 | static inline int dqput_blocks(struct dquot *dquot) | 854 | static inline int dqput_blocks(struct dquot *dquot) |
818 | { | 855 | { |
819 | if (atomic_read(&dquot->dq_count) <= 1) | 856 | if (atomic_read(&dquot->dq_count) <= 1) |
@@ -821,22 +858,27 @@ static inline int dqput_blocks(struct dquot *dquot) | |||
821 | return 0; | 858 | return 0; |
822 | } | 859 | } |
823 | 860 | ||
824 | /* Remove references to dquots from inode - add dquot to list for freeing if needed */ | 861 | /* |
825 | /* We can't race with anybody because we hold dqptr_sem for writing... */ | 862 | * Remove references to dquots from inode and add dquot to list for freeing |
863 | * if we have the last referece to dquot | ||
864 | * We can't race with anybody because we hold dqptr_sem for writing... | ||
865 | */ | ||
826 | static int remove_inode_dquot_ref(struct inode *inode, int type, | 866 | static int remove_inode_dquot_ref(struct inode *inode, int type, |
827 | struct list_head *tofree_head) | 867 | struct list_head *tofree_head) |
828 | { | 868 | { |
829 | struct dquot *dquot = inode->i_dquot[type]; | 869 | struct dquot *dquot = inode->i_dquot[type]; |
830 | 870 | ||
831 | inode->i_dquot[type] = NODQUOT; | 871 | inode->i_dquot[type] = NULL; |
832 | if (dquot != NODQUOT) { | 872 | if (dquot) { |
833 | if (dqput_blocks(dquot)) { | 873 | if (dqput_blocks(dquot)) { |
834 | #ifdef __DQUOT_PARANOIA | 874 | #ifdef __DQUOT_PARANOIA |
835 | if (atomic_read(&dquot->dq_count) != 1) | 875 | if (atomic_read(&dquot->dq_count) != 1) |
836 | printk(KERN_WARNING "VFS: Adding dquot with dq_count %d to dispose list.\n", atomic_read(&dquot->dq_count)); | 876 | printk(KERN_WARNING "VFS: Adding dquot with dq_count %d to dispose list.\n", atomic_read(&dquot->dq_count)); |
837 | #endif | 877 | #endif |
838 | spin_lock(&dq_list_lock); | 878 | spin_lock(&dq_list_lock); |
839 | list_add(&dquot->dq_free, tofree_head); /* As dquot must have currently users it can't be on the free list... */ | 879 | /* As dquot must have currently users it can't be on |
880 | * the free list... */ | ||
881 | list_add(&dquot->dq_free, tofree_head); | ||
840 | spin_unlock(&dq_list_lock); | 882 | spin_unlock(&dq_list_lock); |
841 | return 1; | 883 | return 1; |
842 | } | 884 | } |
@@ -846,19 +888,22 @@ static int remove_inode_dquot_ref(struct inode *inode, int type, | |||
846 | return 0; | 888 | return 0; |
847 | } | 889 | } |
848 | 890 | ||
849 | /* Free list of dquots - called from inode.c */ | 891 | /* |
850 | /* dquots are removed from inodes, no new references can be got so we are the only ones holding reference */ | 892 | * Free list of dquots |
893 | * Dquots are removed from inodes and no new references can be got so we are | ||
894 | * the only ones holding reference | ||
895 | */ | ||
851 | static void put_dquot_list(struct list_head *tofree_head) | 896 | static void put_dquot_list(struct list_head *tofree_head) |
852 | { | 897 | { |
853 | struct list_head *act_head; | 898 | struct list_head *act_head; |
854 | struct dquot *dquot; | 899 | struct dquot *dquot; |
855 | 900 | ||
856 | act_head = tofree_head->next; | 901 | act_head = tofree_head->next; |
857 | /* So now we have dquots on the list... Just free them */ | ||
858 | while (act_head != tofree_head) { | 902 | while (act_head != tofree_head) { |
859 | dquot = list_entry(act_head, struct dquot, dq_free); | 903 | dquot = list_entry(act_head, struct dquot, dq_free); |
860 | act_head = act_head->next; | 904 | act_head = act_head->next; |
861 | list_del_init(&dquot->dq_free); /* Remove dquot from the list so we won't have problems... */ | 905 | /* Remove dquot from the list so we won't have problems... */ |
906 | list_del_init(&dquot->dq_free); | ||
862 | dqput(dquot); | 907 | dqput(dquot); |
863 | } | 908 | } |
864 | } | 909 | } |
@@ -870,6 +915,12 @@ static void remove_dquot_ref(struct super_block *sb, int type, | |||
870 | 915 | ||
871 | spin_lock(&inode_lock); | 916 | spin_lock(&inode_lock); |
872 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 917 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
918 | /* | ||
919 | * We have to scan also I_NEW inodes because they can already | ||
920 | * have quota pointer initialized. Luckily, we need to touch | ||
921 | * only quota pointers and these have separate locking | ||
922 | * (dqptr_sem). | ||
923 | */ | ||
873 | if (!IS_NOQUOTA(inode)) | 924 | if (!IS_NOQUOTA(inode)) |
874 | remove_inode_dquot_ref(inode, type, tofree_head); | 925 | remove_inode_dquot_ref(inode, type, tofree_head); |
875 | } | 926 | } |
@@ -899,7 +950,29 @@ static inline void dquot_incr_space(struct dquot *dquot, qsize_t number) | |||
899 | dquot->dq_dqb.dqb_curspace += number; | 950 | dquot->dq_dqb.dqb_curspace += number; |
900 | } | 951 | } |
901 | 952 | ||
902 | static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number) | 953 | static inline void dquot_resv_space(struct dquot *dquot, qsize_t number) |
954 | { | ||
955 | dquot->dq_dqb.dqb_rsvspace += number; | ||
956 | } | ||
957 | |||
958 | /* | ||
959 | * Claim reserved quota space | ||
960 | */ | ||
961 | static void dquot_claim_reserved_space(struct dquot *dquot, | ||
962 | qsize_t number) | ||
963 | { | ||
964 | WARN_ON(dquot->dq_dqb.dqb_rsvspace < number); | ||
965 | dquot->dq_dqb.dqb_curspace += number; | ||
966 | dquot->dq_dqb.dqb_rsvspace -= number; | ||
967 | } | ||
968 | |||
969 | static inline | ||
970 | void dquot_free_reserved_space(struct dquot *dquot, qsize_t number) | ||
971 | { | ||
972 | dquot->dq_dqb.dqb_rsvspace -= number; | ||
973 | } | ||
974 | |||
975 | static void dquot_decr_inodes(struct dquot *dquot, qsize_t number) | ||
903 | { | 976 | { |
904 | if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE || | 977 | if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE || |
905 | dquot->dq_dqb.dqb_curinodes >= number) | 978 | dquot->dq_dqb.dqb_curinodes >= number) |
@@ -911,7 +984,7 @@ static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number) | |||
911 | clear_bit(DQ_INODES_B, &dquot->dq_flags); | 984 | clear_bit(DQ_INODES_B, &dquot->dq_flags); |
912 | } | 985 | } |
913 | 986 | ||
914 | static inline void dquot_decr_space(struct dquot *dquot, qsize_t number) | 987 | static void dquot_decr_space(struct dquot *dquot, qsize_t number) |
915 | { | 988 | { |
916 | if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE || | 989 | if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE || |
917 | dquot->dq_dqb.dqb_curspace >= number) | 990 | dquot->dq_dqb.dqb_curspace >= number) |
@@ -938,7 +1011,7 @@ static int warning_issued(struct dquot *dquot, const int warntype) | |||
938 | #ifdef CONFIG_PRINT_QUOTA_WARNING | 1011 | #ifdef CONFIG_PRINT_QUOTA_WARNING |
939 | static int flag_print_warnings = 1; | 1012 | static int flag_print_warnings = 1; |
940 | 1013 | ||
941 | static inline int need_print_warning(struct dquot *dquot) | 1014 | static int need_print_warning(struct dquot *dquot) |
942 | { | 1015 | { |
943 | if (!flag_print_warnings) | 1016 | if (!flag_print_warnings) |
944 | return 0; | 1017 | return 0; |
@@ -1065,13 +1138,17 @@ err_out: | |||
1065 | kfree_skb(skb); | 1138 | kfree_skb(skb); |
1066 | } | 1139 | } |
1067 | #endif | 1140 | #endif |
1068 | 1141 | /* | |
1069 | static inline void flush_warnings(struct dquot * const *dquots, char *warntype) | 1142 | * Write warnings to the console and send warning messages over netlink. |
1143 | * | ||
1144 | * Note that this function can sleep. | ||
1145 | */ | ||
1146 | static void flush_warnings(struct dquot *const *dquots, char *warntype) | ||
1070 | { | 1147 | { |
1071 | int i; | 1148 | int i; |
1072 | 1149 | ||
1073 | for (i = 0; i < MAXQUOTAS; i++) | 1150 | for (i = 0; i < MAXQUOTAS; i++) |
1074 | if (dquots[i] != NODQUOT && warntype[i] != QUOTA_NL_NOWARN && | 1151 | if (dquots[i] && warntype[i] != QUOTA_NL_NOWARN && |
1075 | !warning_issued(dquots[i], warntype[i])) { | 1152 | !warning_issued(dquots[i], warntype[i])) { |
1076 | #ifdef CONFIG_PRINT_QUOTA_WARNING | 1153 | #ifdef CONFIG_PRINT_QUOTA_WARNING |
1077 | print_warning(dquots[i], warntype[i]); | 1154 | print_warning(dquots[i], warntype[i]); |
@@ -1082,42 +1159,47 @@ static inline void flush_warnings(struct dquot * const *dquots, char *warntype) | |||
1082 | } | 1159 | } |
1083 | } | 1160 | } |
1084 | 1161 | ||
1085 | static inline char ignore_hardlimit(struct dquot *dquot) | 1162 | static int ignore_hardlimit(struct dquot *dquot) |
1086 | { | 1163 | { |
1087 | struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_type]; | 1164 | struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_type]; |
1088 | 1165 | ||
1089 | return capable(CAP_SYS_RESOURCE) && | 1166 | return capable(CAP_SYS_RESOURCE) && |
1090 | (info->dqi_format->qf_fmt_id != QFMT_VFS_OLD || !(info->dqi_flags & V1_DQF_RSQUASH)); | 1167 | (info->dqi_format->qf_fmt_id != QFMT_VFS_OLD || |
1168 | !(info->dqi_flags & V1_DQF_RSQUASH)); | ||
1091 | } | 1169 | } |
1092 | 1170 | ||
1093 | /* needs dq_data_lock */ | 1171 | /* needs dq_data_lock */ |
1094 | static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype) | 1172 | static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype) |
1095 | { | 1173 | { |
1174 | qsize_t newinodes = dquot->dq_dqb.dqb_curinodes + inodes; | ||
1175 | |||
1096 | *warntype = QUOTA_NL_NOWARN; | 1176 | *warntype = QUOTA_NL_NOWARN; |
1097 | if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) || | 1177 | if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) || |
1098 | test_bit(DQ_FAKE_B, &dquot->dq_flags)) | 1178 | test_bit(DQ_FAKE_B, &dquot->dq_flags)) |
1099 | return QUOTA_OK; | 1179 | return QUOTA_OK; |
1100 | 1180 | ||
1101 | if (dquot->dq_dqb.dqb_ihardlimit && | 1181 | if (dquot->dq_dqb.dqb_ihardlimit && |
1102 | (dquot->dq_dqb.dqb_curinodes + inodes) > dquot->dq_dqb.dqb_ihardlimit && | 1182 | newinodes > dquot->dq_dqb.dqb_ihardlimit && |
1103 | !ignore_hardlimit(dquot)) { | 1183 | !ignore_hardlimit(dquot)) { |
1104 | *warntype = QUOTA_NL_IHARDWARN; | 1184 | *warntype = QUOTA_NL_IHARDWARN; |
1105 | return NO_QUOTA; | 1185 | return NO_QUOTA; |
1106 | } | 1186 | } |
1107 | 1187 | ||
1108 | if (dquot->dq_dqb.dqb_isoftlimit && | 1188 | if (dquot->dq_dqb.dqb_isoftlimit && |
1109 | (dquot->dq_dqb.dqb_curinodes + inodes) > dquot->dq_dqb.dqb_isoftlimit && | 1189 | newinodes > dquot->dq_dqb.dqb_isoftlimit && |
1110 | dquot->dq_dqb.dqb_itime && get_seconds() >= dquot->dq_dqb.dqb_itime && | 1190 | dquot->dq_dqb.dqb_itime && |
1191 | get_seconds() >= dquot->dq_dqb.dqb_itime && | ||
1111 | !ignore_hardlimit(dquot)) { | 1192 | !ignore_hardlimit(dquot)) { |
1112 | *warntype = QUOTA_NL_ISOFTLONGWARN; | 1193 | *warntype = QUOTA_NL_ISOFTLONGWARN; |
1113 | return NO_QUOTA; | 1194 | return NO_QUOTA; |
1114 | } | 1195 | } |
1115 | 1196 | ||
1116 | if (dquot->dq_dqb.dqb_isoftlimit && | 1197 | if (dquot->dq_dqb.dqb_isoftlimit && |
1117 | (dquot->dq_dqb.dqb_curinodes + inodes) > dquot->dq_dqb.dqb_isoftlimit && | 1198 | newinodes > dquot->dq_dqb.dqb_isoftlimit && |
1118 | dquot->dq_dqb.dqb_itime == 0) { | 1199 | dquot->dq_dqb.dqb_itime == 0) { |
1119 | *warntype = QUOTA_NL_ISOFTWARN; | 1200 | *warntype = QUOTA_NL_ISOFTWARN; |
1120 | dquot->dq_dqb.dqb_itime = get_seconds() + sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_igrace; | 1201 | dquot->dq_dqb.dqb_itime = get_seconds() + |
1202 | sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_igrace; | ||
1121 | } | 1203 | } |
1122 | 1204 | ||
1123 | return QUOTA_OK; | 1205 | return QUOTA_OK; |
@@ -1126,13 +1208,19 @@ static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype) | |||
1126 | /* needs dq_data_lock */ | 1208 | /* needs dq_data_lock */ |
1127 | static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *warntype) | 1209 | static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *warntype) |
1128 | { | 1210 | { |
1211 | qsize_t tspace; | ||
1212 | struct super_block *sb = dquot->dq_sb; | ||
1213 | |||
1129 | *warntype = QUOTA_NL_NOWARN; | 1214 | *warntype = QUOTA_NL_NOWARN; |
1130 | if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) || | 1215 | if (!sb_has_quota_limits_enabled(sb, dquot->dq_type) || |
1131 | test_bit(DQ_FAKE_B, &dquot->dq_flags)) | 1216 | test_bit(DQ_FAKE_B, &dquot->dq_flags)) |
1132 | return QUOTA_OK; | 1217 | return QUOTA_OK; |
1133 | 1218 | ||
1219 | tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace | ||
1220 | + space; | ||
1221 | |||
1134 | if (dquot->dq_dqb.dqb_bhardlimit && | 1222 | if (dquot->dq_dqb.dqb_bhardlimit && |
1135 | dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bhardlimit && | 1223 | tspace > dquot->dq_dqb.dqb_bhardlimit && |
1136 | !ignore_hardlimit(dquot)) { | 1224 | !ignore_hardlimit(dquot)) { |
1137 | if (!prealloc) | 1225 | if (!prealloc) |
1138 | *warntype = QUOTA_NL_BHARDWARN; | 1226 | *warntype = QUOTA_NL_BHARDWARN; |
@@ -1140,8 +1228,9 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war | |||
1140 | } | 1228 | } |
1141 | 1229 | ||
1142 | if (dquot->dq_dqb.dqb_bsoftlimit && | 1230 | if (dquot->dq_dqb.dqb_bsoftlimit && |
1143 | dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bsoftlimit && | 1231 | tspace > dquot->dq_dqb.dqb_bsoftlimit && |
1144 | dquot->dq_dqb.dqb_btime && get_seconds() >= dquot->dq_dqb.dqb_btime && | 1232 | dquot->dq_dqb.dqb_btime && |
1233 | get_seconds() >= dquot->dq_dqb.dqb_btime && | ||
1145 | !ignore_hardlimit(dquot)) { | 1234 | !ignore_hardlimit(dquot)) { |
1146 | if (!prealloc) | 1235 | if (!prealloc) |
1147 | *warntype = QUOTA_NL_BSOFTLONGWARN; | 1236 | *warntype = QUOTA_NL_BSOFTLONGWARN; |
@@ -1149,11 +1238,12 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war | |||
1149 | } | 1238 | } |
1150 | 1239 | ||
1151 | if (dquot->dq_dqb.dqb_bsoftlimit && | 1240 | if (dquot->dq_dqb.dqb_bsoftlimit && |
1152 | dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bsoftlimit && | 1241 | tspace > dquot->dq_dqb.dqb_bsoftlimit && |
1153 | dquot->dq_dqb.dqb_btime == 0) { | 1242 | dquot->dq_dqb.dqb_btime == 0) { |
1154 | if (!prealloc) { | 1243 | if (!prealloc) { |
1155 | *warntype = QUOTA_NL_BSOFTWARN; | 1244 | *warntype = QUOTA_NL_BSOFTWARN; |
1156 | dquot->dq_dqb.dqb_btime = get_seconds() + sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_bgrace; | 1245 | dquot->dq_dqb.dqb_btime = get_seconds() + |
1246 | sb_dqopt(sb)->info[dquot->dq_type].dqi_bgrace; | ||
1157 | } | 1247 | } |
1158 | else | 1248 | else |
1159 | /* | 1249 | /* |
@@ -1168,15 +1258,18 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war | |||
1168 | 1258 | ||
1169 | static int info_idq_free(struct dquot *dquot, qsize_t inodes) | 1259 | static int info_idq_free(struct dquot *dquot, qsize_t inodes) |
1170 | { | 1260 | { |
1261 | qsize_t newinodes; | ||
1262 | |||
1171 | if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || | 1263 | if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || |
1172 | dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit || | 1264 | dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit || |
1173 | !sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type)) | 1265 | !sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type)) |
1174 | return QUOTA_NL_NOWARN; | 1266 | return QUOTA_NL_NOWARN; |
1175 | 1267 | ||
1176 | if (dquot->dq_dqb.dqb_curinodes - inodes <= dquot->dq_dqb.dqb_isoftlimit) | 1268 | newinodes = dquot->dq_dqb.dqb_curinodes - inodes; |
1269 | if (newinodes <= dquot->dq_dqb.dqb_isoftlimit) | ||
1177 | return QUOTA_NL_ISOFTBELOW; | 1270 | return QUOTA_NL_ISOFTBELOW; |
1178 | if (dquot->dq_dqb.dqb_curinodes >= dquot->dq_dqb.dqb_ihardlimit && | 1271 | if (dquot->dq_dqb.dqb_curinodes >= dquot->dq_dqb.dqb_ihardlimit && |
1179 | dquot->dq_dqb.dqb_curinodes - inodes < dquot->dq_dqb.dqb_ihardlimit) | 1272 | newinodes < dquot->dq_dqb.dqb_ihardlimit) |
1180 | return QUOTA_NL_IHARDBELOW; | 1273 | return QUOTA_NL_IHARDBELOW; |
1181 | return QUOTA_NL_NOWARN; | 1274 | return QUOTA_NL_NOWARN; |
1182 | } | 1275 | } |
@@ -1203,7 +1296,7 @@ int dquot_initialize(struct inode *inode, int type) | |||
1203 | { | 1296 | { |
1204 | unsigned int id = 0; | 1297 | unsigned int id = 0; |
1205 | int cnt, ret = 0; | 1298 | int cnt, ret = 0; |
1206 | struct dquot *got[MAXQUOTAS] = { NODQUOT, NODQUOT }; | 1299 | struct dquot *got[MAXQUOTAS] = { NULL, NULL }; |
1207 | struct super_block *sb = inode->i_sb; | 1300 | struct super_block *sb = inode->i_sb; |
1208 | 1301 | ||
1209 | /* First test before acquiring mutex - solves deadlocks when we | 1302 | /* First test before acquiring mutex - solves deadlocks when we |
@@ -1236,9 +1329,9 @@ int dquot_initialize(struct inode *inode, int type) | |||
1236 | /* Avoid races with quotaoff() */ | 1329 | /* Avoid races with quotaoff() */ |
1237 | if (!sb_has_quota_active(sb, cnt)) | 1330 | if (!sb_has_quota_active(sb, cnt)) |
1238 | continue; | 1331 | continue; |
1239 | if (inode->i_dquot[cnt] == NODQUOT) { | 1332 | if (!inode->i_dquot[cnt]) { |
1240 | inode->i_dquot[cnt] = got[cnt]; | 1333 | inode->i_dquot[cnt] = got[cnt]; |
1241 | got[cnt] = NODQUOT; | 1334 | got[cnt] = NULL; |
1242 | } | 1335 | } |
1243 | } | 1336 | } |
1244 | out_err: | 1337 | out_err: |
@@ -1248,6 +1341,7 @@ out_err: | |||
1248 | dqput(got[cnt]); | 1341 | dqput(got[cnt]); |
1249 | return ret; | 1342 | return ret; |
1250 | } | 1343 | } |
1344 | EXPORT_SYMBOL(dquot_initialize); | ||
1251 | 1345 | ||
1252 | /* | 1346 | /* |
1253 | * Release all quotas referenced by inode | 1347 | * Release all quotas referenced by inode |
@@ -1260,7 +1354,7 @@ int dquot_drop(struct inode *inode) | |||
1260 | down_write(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1354 | down_write(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1261 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1355 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1262 | put[cnt] = inode->i_dquot[cnt]; | 1356 | put[cnt] = inode->i_dquot[cnt]; |
1263 | inode->i_dquot[cnt] = NODQUOT; | 1357 | inode->i_dquot[cnt] = NULL; |
1264 | } | 1358 | } |
1265 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1359 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1266 | 1360 | ||
@@ -1268,6 +1362,7 @@ int dquot_drop(struct inode *inode) | |||
1268 | dqput(put[cnt]); | 1362 | dqput(put[cnt]); |
1269 | return 0; | 1363 | return 0; |
1270 | } | 1364 | } |
1365 | EXPORT_SYMBOL(dquot_drop); | ||
1271 | 1366 | ||
1272 | /* Wrapper to remove references to quota structures from inode */ | 1367 | /* Wrapper to remove references to quota structures from inode */ |
1273 | void vfs_dq_drop(struct inode *inode) | 1368 | void vfs_dq_drop(struct inode *inode) |
@@ -1284,12 +1379,13 @@ void vfs_dq_drop(struct inode *inode) | |||
1284 | * must assure that nobody can come after the DQUOT_DROP and | 1379 | * must assure that nobody can come after the DQUOT_DROP and |
1285 | * add quota pointers back anyway */ | 1380 | * add quota pointers back anyway */ |
1286 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | 1381 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) |
1287 | if (inode->i_dquot[cnt] != NODQUOT) | 1382 | if (inode->i_dquot[cnt]) |
1288 | break; | 1383 | break; |
1289 | if (cnt < MAXQUOTAS) | 1384 | if (cnt < MAXQUOTAS) |
1290 | inode->i_sb->dq_op->drop(inode); | 1385 | inode->i_sb->dq_op->drop(inode); |
1291 | } | 1386 | } |
1292 | } | 1387 | } |
1388 | EXPORT_SYMBOL(vfs_dq_drop); | ||
1293 | 1389 | ||
1294 | /* | 1390 | /* |
1295 | * Following four functions update i_blocks+i_bytes fields and | 1391 | * Following four functions update i_blocks+i_bytes fields and |
@@ -1303,51 +1399,93 @@ void vfs_dq_drop(struct inode *inode) | |||
1303 | /* | 1399 | /* |
1304 | * This operation can block, but only after everything is updated | 1400 | * This operation can block, but only after everything is updated |
1305 | */ | 1401 | */ |
1306 | int dquot_alloc_space(struct inode *inode, qsize_t number, int warn) | 1402 | int __dquot_alloc_space(struct inode *inode, qsize_t number, |
1403 | int warn, int reserve) | ||
1307 | { | 1404 | { |
1308 | int cnt, ret = NO_QUOTA; | 1405 | int cnt, ret = QUOTA_OK; |
1309 | char warntype[MAXQUOTAS]; | 1406 | char warntype[MAXQUOTAS]; |
1310 | 1407 | ||
1311 | /* First test before acquiring mutex - solves deadlocks when we | ||
1312 | * re-enter the quota code and are already holding the mutex */ | ||
1313 | if (IS_NOQUOTA(inode)) { | ||
1314 | out_add: | ||
1315 | inode_add_bytes(inode, number); | ||
1316 | return QUOTA_OK; | ||
1317 | } | ||
1318 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | 1408 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) |
1319 | warntype[cnt] = QUOTA_NL_NOWARN; | 1409 | warntype[cnt] = QUOTA_NL_NOWARN; |
1320 | 1410 | ||
1321 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1322 | if (IS_NOQUOTA(inode)) { /* Now we can do reliable test... */ | ||
1323 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1324 | goto out_add; | ||
1325 | } | ||
1326 | spin_lock(&dq_data_lock); | 1411 | spin_lock(&dq_data_lock); |
1327 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1412 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1328 | if (inode->i_dquot[cnt] == NODQUOT) | 1413 | if (!inode->i_dquot[cnt]) |
1329 | continue; | 1414 | continue; |
1330 | if (check_bdq(inode->i_dquot[cnt], number, warn, warntype+cnt) == NO_QUOTA) | 1415 | if (check_bdq(inode->i_dquot[cnt], number, warn, warntype+cnt) |
1331 | goto warn_put_all; | 1416 | == NO_QUOTA) { |
1417 | ret = NO_QUOTA; | ||
1418 | goto out_unlock; | ||
1419 | } | ||
1332 | } | 1420 | } |
1333 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1421 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1334 | if (inode->i_dquot[cnt] == NODQUOT) | 1422 | if (!inode->i_dquot[cnt]) |
1335 | continue; | 1423 | continue; |
1336 | dquot_incr_space(inode->i_dquot[cnt], number); | 1424 | if (reserve) |
1425 | dquot_resv_space(inode->i_dquot[cnt], number); | ||
1426 | else | ||
1427 | dquot_incr_space(inode->i_dquot[cnt], number); | ||
1337 | } | 1428 | } |
1338 | inode_add_bytes(inode, number); | 1429 | if (!reserve) |
1339 | ret = QUOTA_OK; | 1430 | inode_add_bytes(inode, number); |
1340 | warn_put_all: | 1431 | out_unlock: |
1341 | spin_unlock(&dq_data_lock); | 1432 | spin_unlock(&dq_data_lock); |
1342 | if (ret == QUOTA_OK) | ||
1343 | /* Dirtify all the dquots - this can block when journalling */ | ||
1344 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
1345 | if (inode->i_dquot[cnt]) | ||
1346 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
1347 | flush_warnings(inode->i_dquot, warntype); | 1433 | flush_warnings(inode->i_dquot, warntype); |
1434 | return ret; | ||
1435 | } | ||
1436 | |||
1437 | int dquot_alloc_space(struct inode *inode, qsize_t number, int warn) | ||
1438 | { | ||
1439 | int cnt, ret = QUOTA_OK; | ||
1440 | |||
1441 | /* | ||
1442 | * First test before acquiring mutex - solves deadlocks when we | ||
1443 | * re-enter the quota code and are already holding the mutex | ||
1444 | */ | ||
1445 | if (IS_NOQUOTA(inode)) { | ||
1446 | inode_add_bytes(inode, number); | ||
1447 | goto out; | ||
1448 | } | ||
1449 | |||
1450 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1451 | if (IS_NOQUOTA(inode)) { | ||
1452 | inode_add_bytes(inode, number); | ||
1453 | goto out_unlock; | ||
1454 | } | ||
1455 | |||
1456 | ret = __dquot_alloc_space(inode, number, warn, 0); | ||
1457 | if (ret == NO_QUOTA) | ||
1458 | goto out_unlock; | ||
1459 | |||
1460 | /* Dirtify all the dquots - this can block when journalling */ | ||
1461 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
1462 | if (inode->i_dquot[cnt]) | ||
1463 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
1464 | out_unlock: | ||
1348 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1465 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1466 | out: | ||
1349 | return ret; | 1467 | return ret; |
1350 | } | 1468 | } |
1469 | EXPORT_SYMBOL(dquot_alloc_space); | ||
1470 | |||
1471 | int dquot_reserve_space(struct inode *inode, qsize_t number, int warn) | ||
1472 | { | ||
1473 | int ret = QUOTA_OK; | ||
1474 | |||
1475 | if (IS_NOQUOTA(inode)) | ||
1476 | goto out; | ||
1477 | |||
1478 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1479 | if (IS_NOQUOTA(inode)) | ||
1480 | goto out_unlock; | ||
1481 | |||
1482 | ret = __dquot_alloc_space(inode, number, warn, 1); | ||
1483 | out_unlock: | ||
1484 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1485 | out: | ||
1486 | return ret; | ||
1487 | } | ||
1488 | EXPORT_SYMBOL(dquot_reserve_space); | ||
1351 | 1489 | ||
1352 | /* | 1490 | /* |
1353 | * This operation can block, but only after everything is updated | 1491 | * This operation can block, but only after everything is updated |
@@ -1370,14 +1508,15 @@ int dquot_alloc_inode(const struct inode *inode, qsize_t number) | |||
1370 | } | 1508 | } |
1371 | spin_lock(&dq_data_lock); | 1509 | spin_lock(&dq_data_lock); |
1372 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1510 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1373 | if (inode->i_dquot[cnt] == NODQUOT) | 1511 | if (!inode->i_dquot[cnt]) |
1374 | continue; | 1512 | continue; |
1375 | if (check_idq(inode->i_dquot[cnt], number, warntype+cnt) == NO_QUOTA) | 1513 | if (check_idq(inode->i_dquot[cnt], number, warntype+cnt) |
1514 | == NO_QUOTA) | ||
1376 | goto warn_put_all; | 1515 | goto warn_put_all; |
1377 | } | 1516 | } |
1378 | 1517 | ||
1379 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1518 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1380 | if (inode->i_dquot[cnt] == NODQUOT) | 1519 | if (!inode->i_dquot[cnt]) |
1381 | continue; | 1520 | continue; |
1382 | dquot_incr_inodes(inode->i_dquot[cnt], number); | 1521 | dquot_incr_inodes(inode->i_dquot[cnt], number); |
1383 | } | 1522 | } |
@@ -1393,6 +1532,73 @@ warn_put_all: | |||
1393 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1532 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1394 | return ret; | 1533 | return ret; |
1395 | } | 1534 | } |
1535 | EXPORT_SYMBOL(dquot_alloc_inode); | ||
1536 | |||
1537 | int dquot_claim_space(struct inode *inode, qsize_t number) | ||
1538 | { | ||
1539 | int cnt; | ||
1540 | int ret = QUOTA_OK; | ||
1541 | |||
1542 | if (IS_NOQUOTA(inode)) { | ||
1543 | inode_add_bytes(inode, number); | ||
1544 | goto out; | ||
1545 | } | ||
1546 | |||
1547 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1548 | if (IS_NOQUOTA(inode)) { | ||
1549 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1550 | inode_add_bytes(inode, number); | ||
1551 | goto out; | ||
1552 | } | ||
1553 | |||
1554 | spin_lock(&dq_data_lock); | ||
1555 | /* Claim reserved quotas to allocated quotas */ | ||
1556 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | ||
1557 | if (inode->i_dquot[cnt]) | ||
1558 | dquot_claim_reserved_space(inode->i_dquot[cnt], | ||
1559 | number); | ||
1560 | } | ||
1561 | /* Update inode bytes */ | ||
1562 | inode_add_bytes(inode, number); | ||
1563 | spin_unlock(&dq_data_lock); | ||
1564 | /* Dirtify all the dquots - this can block when journalling */ | ||
1565 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
1566 | if (inode->i_dquot[cnt]) | ||
1567 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
1568 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1569 | out: | ||
1570 | return ret; | ||
1571 | } | ||
1572 | EXPORT_SYMBOL(dquot_claim_space); | ||
1573 | |||
1574 | /* | ||
1575 | * Release reserved quota space | ||
1576 | */ | ||
1577 | void dquot_release_reserved_space(struct inode *inode, qsize_t number) | ||
1578 | { | ||
1579 | int cnt; | ||
1580 | |||
1581 | if (IS_NOQUOTA(inode)) | ||
1582 | goto out; | ||
1583 | |||
1584 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1585 | if (IS_NOQUOTA(inode)) | ||
1586 | goto out_unlock; | ||
1587 | |||
1588 | spin_lock(&dq_data_lock); | ||
1589 | /* Release reserved dquots */ | ||
1590 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | ||
1591 | if (inode->i_dquot[cnt]) | ||
1592 | dquot_free_reserved_space(inode->i_dquot[cnt], number); | ||
1593 | } | ||
1594 | spin_unlock(&dq_data_lock); | ||
1595 | |||
1596 | out_unlock: | ||
1597 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1598 | out: | ||
1599 | return; | ||
1600 | } | ||
1601 | EXPORT_SYMBOL(dquot_release_reserved_space); | ||
1396 | 1602 | ||
1397 | /* | 1603 | /* |
1398 | * This operation can block, but only after everything is updated | 1604 | * This operation can block, but only after everything is updated |
@@ -1418,7 +1624,7 @@ out_sub: | |||
1418 | } | 1624 | } |
1419 | spin_lock(&dq_data_lock); | 1625 | spin_lock(&dq_data_lock); |
1420 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1626 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1421 | if (inode->i_dquot[cnt] == NODQUOT) | 1627 | if (!inode->i_dquot[cnt]) |
1422 | continue; | 1628 | continue; |
1423 | warntype[cnt] = info_bdq_free(inode->i_dquot[cnt], number); | 1629 | warntype[cnt] = info_bdq_free(inode->i_dquot[cnt], number); |
1424 | dquot_decr_space(inode->i_dquot[cnt], number); | 1630 | dquot_decr_space(inode->i_dquot[cnt], number); |
@@ -1433,6 +1639,7 @@ out_sub: | |||
1433 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1639 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1434 | return QUOTA_OK; | 1640 | return QUOTA_OK; |
1435 | } | 1641 | } |
1642 | EXPORT_SYMBOL(dquot_free_space); | ||
1436 | 1643 | ||
1437 | /* | 1644 | /* |
1438 | * This operation can block, but only after everything is updated | 1645 | * This operation can block, but only after everything is updated |
@@ -1455,7 +1662,7 @@ int dquot_free_inode(const struct inode *inode, qsize_t number) | |||
1455 | } | 1662 | } |
1456 | spin_lock(&dq_data_lock); | 1663 | spin_lock(&dq_data_lock); |
1457 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1664 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1458 | if (inode->i_dquot[cnt] == NODQUOT) | 1665 | if (!inode->i_dquot[cnt]) |
1459 | continue; | 1666 | continue; |
1460 | warntype[cnt] = info_idq_free(inode->i_dquot[cnt], number); | 1667 | warntype[cnt] = info_idq_free(inode->i_dquot[cnt], number); |
1461 | dquot_decr_inodes(inode->i_dquot[cnt], number); | 1668 | dquot_decr_inodes(inode->i_dquot[cnt], number); |
@@ -1469,6 +1676,20 @@ int dquot_free_inode(const struct inode *inode, qsize_t number) | |||
1469 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1676 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1470 | return QUOTA_OK; | 1677 | return QUOTA_OK; |
1471 | } | 1678 | } |
1679 | EXPORT_SYMBOL(dquot_free_inode); | ||
1680 | |||
1681 | /* | ||
1682 | * call back function, get reserved quota space from underlying fs | ||
1683 | */ | ||
1684 | qsize_t dquot_get_reserved_space(struct inode *inode) | ||
1685 | { | ||
1686 | qsize_t reserved_space = 0; | ||
1687 | |||
1688 | if (sb_any_quota_active(inode->i_sb) && | ||
1689 | inode->i_sb->dq_op->get_reserved_space) | ||
1690 | reserved_space = inode->i_sb->dq_op->get_reserved_space(inode); | ||
1691 | return reserved_space; | ||
1692 | } | ||
1472 | 1693 | ||
1473 | /* | 1694 | /* |
1474 | * Transfer the number of inode and blocks from one diskquota to an other. | 1695 | * Transfer the number of inode and blocks from one diskquota to an other. |
@@ -1478,7 +1699,8 @@ int dquot_free_inode(const struct inode *inode, qsize_t number) | |||
1478 | */ | 1699 | */ |
1479 | int dquot_transfer(struct inode *inode, struct iattr *iattr) | 1700 | int dquot_transfer(struct inode *inode, struct iattr *iattr) |
1480 | { | 1701 | { |
1481 | qsize_t space; | 1702 | qsize_t space, cur_space; |
1703 | qsize_t rsv_space = 0; | ||
1482 | struct dquot *transfer_from[MAXQUOTAS]; | 1704 | struct dquot *transfer_from[MAXQUOTAS]; |
1483 | struct dquot *transfer_to[MAXQUOTAS]; | 1705 | struct dquot *transfer_to[MAXQUOTAS]; |
1484 | int cnt, ret = QUOTA_OK; | 1706 | int cnt, ret = QUOTA_OK; |
@@ -1493,22 +1715,16 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) | |||
1493 | return QUOTA_OK; | 1715 | return QUOTA_OK; |
1494 | /* Initialize the arrays */ | 1716 | /* Initialize the arrays */ |
1495 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1717 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1496 | transfer_from[cnt] = NODQUOT; | 1718 | transfer_from[cnt] = NULL; |
1497 | transfer_to[cnt] = NODQUOT; | 1719 | transfer_to[cnt] = NULL; |
1498 | warntype_to[cnt] = QUOTA_NL_NOWARN; | 1720 | warntype_to[cnt] = QUOTA_NL_NOWARN; |
1499 | switch (cnt) { | ||
1500 | case USRQUOTA: | ||
1501 | if (!chuid) | ||
1502 | continue; | ||
1503 | transfer_to[cnt] = dqget(inode->i_sb, iattr->ia_uid, cnt); | ||
1504 | break; | ||
1505 | case GRPQUOTA: | ||
1506 | if (!chgid) | ||
1507 | continue; | ||
1508 | transfer_to[cnt] = dqget(inode->i_sb, iattr->ia_gid, cnt); | ||
1509 | break; | ||
1510 | } | ||
1511 | } | 1721 | } |
1722 | if (chuid) | ||
1723 | transfer_to[USRQUOTA] = dqget(inode->i_sb, iattr->ia_uid, | ||
1724 | USRQUOTA); | ||
1725 | if (chgid) | ||
1726 | transfer_to[GRPQUOTA] = dqget(inode->i_sb, iattr->ia_gid, | ||
1727 | GRPQUOTA); | ||
1512 | 1728 | ||
1513 | down_write(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1729 | down_write(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1514 | /* Now recheck reliably when holding dqptr_sem */ | 1730 | /* Now recheck reliably when holding dqptr_sem */ |
@@ -1517,10 +1733,12 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) | |||
1517 | goto put_all; | 1733 | goto put_all; |
1518 | } | 1734 | } |
1519 | spin_lock(&dq_data_lock); | 1735 | spin_lock(&dq_data_lock); |
1520 | space = inode_get_bytes(inode); | 1736 | cur_space = inode_get_bytes(inode); |
1737 | rsv_space = dquot_get_reserved_space(inode); | ||
1738 | space = cur_space + rsv_space; | ||
1521 | /* Build the transfer_from list and check the limits */ | 1739 | /* Build the transfer_from list and check the limits */ |
1522 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1740 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1523 | if (transfer_to[cnt] == NODQUOT) | 1741 | if (!transfer_to[cnt]) |
1524 | continue; | 1742 | continue; |
1525 | transfer_from[cnt] = inode->i_dquot[cnt]; | 1743 | transfer_from[cnt] = inode->i_dquot[cnt]; |
1526 | if (check_idq(transfer_to[cnt], 1, warntype_to + cnt) == | 1744 | if (check_idq(transfer_to[cnt], 1, warntype_to + cnt) == |
@@ -1536,7 +1754,7 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) | |||
1536 | /* | 1754 | /* |
1537 | * Skip changes for same uid or gid or for turned off quota-type. | 1755 | * Skip changes for same uid or gid or for turned off quota-type. |
1538 | */ | 1756 | */ |
1539 | if (transfer_to[cnt] == NODQUOT) | 1757 | if (!transfer_to[cnt]) |
1540 | continue; | 1758 | continue; |
1541 | 1759 | ||
1542 | /* Due to IO error we might not have transfer_from[] structure */ | 1760 | /* Due to IO error we might not have transfer_from[] structure */ |
@@ -1546,11 +1764,14 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) | |||
1546 | warntype_from_space[cnt] = | 1764 | warntype_from_space[cnt] = |
1547 | info_bdq_free(transfer_from[cnt], space); | 1765 | info_bdq_free(transfer_from[cnt], space); |
1548 | dquot_decr_inodes(transfer_from[cnt], 1); | 1766 | dquot_decr_inodes(transfer_from[cnt], 1); |
1549 | dquot_decr_space(transfer_from[cnt], space); | 1767 | dquot_decr_space(transfer_from[cnt], cur_space); |
1768 | dquot_free_reserved_space(transfer_from[cnt], | ||
1769 | rsv_space); | ||
1550 | } | 1770 | } |
1551 | 1771 | ||
1552 | dquot_incr_inodes(transfer_to[cnt], 1); | 1772 | dquot_incr_inodes(transfer_to[cnt], 1); |
1553 | dquot_incr_space(transfer_to[cnt], space); | 1773 | dquot_incr_space(transfer_to[cnt], cur_space); |
1774 | dquot_resv_space(transfer_to[cnt], rsv_space); | ||
1554 | 1775 | ||
1555 | inode->i_dquot[cnt] = transfer_to[cnt]; | 1776 | inode->i_dquot[cnt] = transfer_to[cnt]; |
1556 | } | 1777 | } |
@@ -1564,7 +1785,7 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) | |||
1564 | if (transfer_to[cnt]) { | 1785 | if (transfer_to[cnt]) { |
1565 | mark_dquot_dirty(transfer_to[cnt]); | 1786 | mark_dquot_dirty(transfer_to[cnt]); |
1566 | /* The reference we got is transferred to the inode */ | 1787 | /* The reference we got is transferred to the inode */ |
1567 | transfer_to[cnt] = NODQUOT; | 1788 | transfer_to[cnt] = NULL; |
1568 | } | 1789 | } |
1569 | } | 1790 | } |
1570 | warn_put_all: | 1791 | warn_put_all: |
@@ -1582,10 +1803,11 @@ over_quota: | |||
1582 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1803 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1583 | /* Clear dquot pointers we don't want to dqput() */ | 1804 | /* Clear dquot pointers we don't want to dqput() */ |
1584 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | 1805 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) |
1585 | transfer_from[cnt] = NODQUOT; | 1806 | transfer_from[cnt] = NULL; |
1586 | ret = NO_QUOTA; | 1807 | ret = NO_QUOTA; |
1587 | goto warn_put_all; | 1808 | goto warn_put_all; |
1588 | } | 1809 | } |
1810 | EXPORT_SYMBOL(dquot_transfer); | ||
1589 | 1811 | ||
1590 | /* Wrapper for transferring ownership of an inode */ | 1812 | /* Wrapper for transferring ownership of an inode */ |
1591 | int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) | 1813 | int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) |
@@ -1597,7 +1819,7 @@ int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) | |||
1597 | } | 1819 | } |
1598 | return 0; | 1820 | return 0; |
1599 | } | 1821 | } |
1600 | 1822 | EXPORT_SYMBOL(vfs_dq_transfer); | |
1601 | 1823 | ||
1602 | /* | 1824 | /* |
1603 | * Write info of quota file to disk | 1825 | * Write info of quota file to disk |
@@ -1612,6 +1834,7 @@ int dquot_commit_info(struct super_block *sb, int type) | |||
1612 | mutex_unlock(&dqopt->dqio_mutex); | 1834 | mutex_unlock(&dqopt->dqio_mutex); |
1613 | return ret; | 1835 | return ret; |
1614 | } | 1836 | } |
1837 | EXPORT_SYMBOL(dquot_commit_info); | ||
1615 | 1838 | ||
1616 | /* | 1839 | /* |
1617 | * Definitions of diskquota operations. | 1840 | * Definitions of diskquota operations. |
@@ -1697,8 +1920,8 @@ int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags) | |||
1697 | drop_dquot_ref(sb, cnt); | 1920 | drop_dquot_ref(sb, cnt); |
1698 | invalidate_dquots(sb, cnt); | 1921 | invalidate_dquots(sb, cnt); |
1699 | /* | 1922 | /* |
1700 | * Now all dquots should be invalidated, all writes done so we should be only | 1923 | * Now all dquots should be invalidated, all writes done so we |
1701 | * users of the info. No locks needed. | 1924 | * should be only users of the info. No locks needed. |
1702 | */ | 1925 | */ |
1703 | if (info_dirty(&dqopt->info[cnt])) | 1926 | if (info_dirty(&dqopt->info[cnt])) |
1704 | sb->dq_op->write_info(sb, cnt); | 1927 | sb->dq_op->write_info(sb, cnt); |
@@ -1736,10 +1959,12 @@ int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags) | |||
1736 | /* If quota was reenabled in the meantime, we have | 1959 | /* If quota was reenabled in the meantime, we have |
1737 | * nothing to do */ | 1960 | * nothing to do */ |
1738 | if (!sb_has_quota_loaded(sb, cnt)) { | 1961 | if (!sb_has_quota_loaded(sb, cnt)) { |
1739 | mutex_lock_nested(&toputinode[cnt]->i_mutex, I_MUTEX_QUOTA); | 1962 | mutex_lock_nested(&toputinode[cnt]->i_mutex, |
1963 | I_MUTEX_QUOTA); | ||
1740 | toputinode[cnt]->i_flags &= ~(S_IMMUTABLE | | 1964 | toputinode[cnt]->i_flags &= ~(S_IMMUTABLE | |
1741 | S_NOATIME | S_NOQUOTA); | 1965 | S_NOATIME | S_NOQUOTA); |
1742 | truncate_inode_pages(&toputinode[cnt]->i_data, 0); | 1966 | truncate_inode_pages(&toputinode[cnt]->i_data, |
1967 | 0); | ||
1743 | mutex_unlock(&toputinode[cnt]->i_mutex); | 1968 | mutex_unlock(&toputinode[cnt]->i_mutex); |
1744 | mark_inode_dirty(toputinode[cnt]); | 1969 | mark_inode_dirty(toputinode[cnt]); |
1745 | } | 1970 | } |
@@ -1764,13 +1989,14 @@ put_inodes: | |||
1764 | } | 1989 | } |
1765 | return ret; | 1990 | return ret; |
1766 | } | 1991 | } |
1992 | EXPORT_SYMBOL(vfs_quota_disable); | ||
1767 | 1993 | ||
1768 | int vfs_quota_off(struct super_block *sb, int type, int remount) | 1994 | int vfs_quota_off(struct super_block *sb, int type, int remount) |
1769 | { | 1995 | { |
1770 | return vfs_quota_disable(sb, type, remount ? DQUOT_SUSPENDED : | 1996 | return vfs_quota_disable(sb, type, remount ? DQUOT_SUSPENDED : |
1771 | (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED)); | 1997 | (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED)); |
1772 | } | 1998 | } |
1773 | 1999 | EXPORT_SYMBOL(vfs_quota_off); | |
1774 | /* | 2000 | /* |
1775 | * Turn quotas on on a device | 2001 | * Turn quotas on on a device |
1776 | */ | 2002 | */ |
@@ -1828,7 +2054,8 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id, | |||
1828 | * possible) Also nobody should write to the file - we use | 2054 | * possible) Also nobody should write to the file - we use |
1829 | * special IO operations which ignore the immutable bit. */ | 2055 | * special IO operations which ignore the immutable bit. */ |
1830 | down_write(&dqopt->dqptr_sem); | 2056 | down_write(&dqopt->dqptr_sem); |
1831 | oldflags = inode->i_flags & (S_NOATIME | S_IMMUTABLE | S_NOQUOTA); | 2057 | oldflags = inode->i_flags & (S_NOATIME | S_IMMUTABLE | |
2058 | S_NOQUOTA); | ||
1832 | inode->i_flags |= S_NOQUOTA | S_NOATIME | S_IMMUTABLE; | 2059 | inode->i_flags |= S_NOQUOTA | S_NOATIME | S_IMMUTABLE; |
1833 | up_write(&dqopt->dqptr_sem); | 2060 | up_write(&dqopt->dqptr_sem); |
1834 | sb->dq_op->drop(inode); | 2061 | sb->dq_op->drop(inode); |
@@ -1847,7 +2074,8 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id, | |||
1847 | dqopt->info[type].dqi_fmt_id = format_id; | 2074 | dqopt->info[type].dqi_fmt_id = format_id; |
1848 | INIT_LIST_HEAD(&dqopt->info[type].dqi_dirty_list); | 2075 | INIT_LIST_HEAD(&dqopt->info[type].dqi_dirty_list); |
1849 | mutex_lock(&dqopt->dqio_mutex); | 2076 | mutex_lock(&dqopt->dqio_mutex); |
1850 | if ((error = dqopt->ops[type]->read_file_info(sb, type)) < 0) { | 2077 | error = dqopt->ops[type]->read_file_info(sb, type); |
2078 | if (error < 0) { | ||
1851 | mutex_unlock(&dqopt->dqio_mutex); | 2079 | mutex_unlock(&dqopt->dqio_mutex); |
1852 | goto out_file_init; | 2080 | goto out_file_init; |
1853 | } | 2081 | } |
@@ -1927,6 +2155,7 @@ int vfs_quota_on_path(struct super_block *sb, int type, int format_id, | |||
1927 | DQUOT_LIMITS_ENABLED); | 2155 | DQUOT_LIMITS_ENABLED); |
1928 | return error; | 2156 | return error; |
1929 | } | 2157 | } |
2158 | EXPORT_SYMBOL(vfs_quota_on_path); | ||
1930 | 2159 | ||
1931 | int vfs_quota_on(struct super_block *sb, int type, int format_id, char *name, | 2160 | int vfs_quota_on(struct super_block *sb, int type, int format_id, char *name, |
1932 | int remount) | 2161 | int remount) |
@@ -1944,6 +2173,7 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *name, | |||
1944 | } | 2173 | } |
1945 | return error; | 2174 | return error; |
1946 | } | 2175 | } |
2176 | EXPORT_SYMBOL(vfs_quota_on); | ||
1947 | 2177 | ||
1948 | /* | 2178 | /* |
1949 | * More powerful function for turning on quotas allowing setting | 2179 | * More powerful function for turning on quotas allowing setting |
@@ -1990,6 +2220,7 @@ out_lock: | |||
1990 | load_quota: | 2220 | load_quota: |
1991 | return vfs_load_quota_inode(inode, type, format_id, flags); | 2221 | return vfs_load_quota_inode(inode, type, format_id, flags); |
1992 | } | 2222 | } |
2223 | EXPORT_SYMBOL(vfs_quota_enable); | ||
1993 | 2224 | ||
1994 | /* | 2225 | /* |
1995 | * This function is used when filesystem needs to initialize quotas | 2226 | * This function is used when filesystem needs to initialize quotas |
@@ -2019,6 +2250,7 @@ out: | |||
2019 | dput(dentry); | 2250 | dput(dentry); |
2020 | return error; | 2251 | return error; |
2021 | } | 2252 | } |
2253 | EXPORT_SYMBOL(vfs_quota_on_mount); | ||
2022 | 2254 | ||
2023 | /* Wrapper to turn on quotas when remounting rw */ | 2255 | /* Wrapper to turn on quotas when remounting rw */ |
2024 | int vfs_dq_quota_on_remount(struct super_block *sb) | 2256 | int vfs_dq_quota_on_remount(struct super_block *sb) |
@@ -2035,6 +2267,7 @@ int vfs_dq_quota_on_remount(struct super_block *sb) | |||
2035 | } | 2267 | } |
2036 | return ret; | 2268 | return ret; |
2037 | } | 2269 | } |
2270 | EXPORT_SYMBOL(vfs_dq_quota_on_remount); | ||
2038 | 2271 | ||
2039 | static inline qsize_t qbtos(qsize_t blocks) | 2272 | static inline qsize_t qbtos(qsize_t blocks) |
2040 | { | 2273 | { |
@@ -2054,7 +2287,7 @@ static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di) | |||
2054 | spin_lock(&dq_data_lock); | 2287 | spin_lock(&dq_data_lock); |
2055 | di->dqb_bhardlimit = stoqb(dm->dqb_bhardlimit); | 2288 | di->dqb_bhardlimit = stoqb(dm->dqb_bhardlimit); |
2056 | di->dqb_bsoftlimit = stoqb(dm->dqb_bsoftlimit); | 2289 | di->dqb_bsoftlimit = stoqb(dm->dqb_bsoftlimit); |
2057 | di->dqb_curspace = dm->dqb_curspace; | 2290 | di->dqb_curspace = dm->dqb_curspace + dm->dqb_rsvspace; |
2058 | di->dqb_ihardlimit = dm->dqb_ihardlimit; | 2291 | di->dqb_ihardlimit = dm->dqb_ihardlimit; |
2059 | di->dqb_isoftlimit = dm->dqb_isoftlimit; | 2292 | di->dqb_isoftlimit = dm->dqb_isoftlimit; |
2060 | di->dqb_curinodes = dm->dqb_curinodes; | 2293 | di->dqb_curinodes = dm->dqb_curinodes; |
@@ -2064,18 +2297,20 @@ static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di) | |||
2064 | spin_unlock(&dq_data_lock); | 2297 | spin_unlock(&dq_data_lock); |
2065 | } | 2298 | } |
2066 | 2299 | ||
2067 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di) | 2300 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, |
2301 | struct if_dqblk *di) | ||
2068 | { | 2302 | { |
2069 | struct dquot *dquot; | 2303 | struct dquot *dquot; |
2070 | 2304 | ||
2071 | dquot = dqget(sb, id, type); | 2305 | dquot = dqget(sb, id, type); |
2072 | if (dquot == NODQUOT) | 2306 | if (!dquot) |
2073 | return -ESRCH; | 2307 | return -ESRCH; |
2074 | do_get_dqblk(dquot, di); | 2308 | do_get_dqblk(dquot, di); |
2075 | dqput(dquot); | 2309 | dqput(dquot); |
2076 | 2310 | ||
2077 | return 0; | 2311 | return 0; |
2078 | } | 2312 | } |
2313 | EXPORT_SYMBOL(vfs_get_dqblk); | ||
2079 | 2314 | ||
2080 | /* Generic routine for setting common part of quota structure */ | 2315 | /* Generic routine for setting common part of quota structure */ |
2081 | static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di) | 2316 | static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di) |
@@ -2094,7 +2329,7 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di) | |||
2094 | 2329 | ||
2095 | spin_lock(&dq_data_lock); | 2330 | spin_lock(&dq_data_lock); |
2096 | if (di->dqb_valid & QIF_SPACE) { | 2331 | if (di->dqb_valid & QIF_SPACE) { |
2097 | dm->dqb_curspace = di->dqb_curspace; | 2332 | dm->dqb_curspace = di->dqb_curspace - dm->dqb_rsvspace; |
2098 | check_blim = 1; | 2333 | check_blim = 1; |
2099 | __set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags); | 2334 | __set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags); |
2100 | } | 2335 | } |
@@ -2127,22 +2362,25 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di) | |||
2127 | } | 2362 | } |
2128 | 2363 | ||
2129 | if (check_blim) { | 2364 | if (check_blim) { |
2130 | if (!dm->dqb_bsoftlimit || dm->dqb_curspace < dm->dqb_bsoftlimit) { | 2365 | if (!dm->dqb_bsoftlimit || |
2366 | dm->dqb_curspace < dm->dqb_bsoftlimit) { | ||
2131 | dm->dqb_btime = 0; | 2367 | dm->dqb_btime = 0; |
2132 | clear_bit(DQ_BLKS_B, &dquot->dq_flags); | 2368 | clear_bit(DQ_BLKS_B, &dquot->dq_flags); |
2133 | } | 2369 | } else if (!(di->dqb_valid & QIF_BTIME)) |
2134 | else if (!(di->dqb_valid & QIF_BTIME)) /* Set grace only if user hasn't provided his own... */ | 2370 | /* Set grace only if user hasn't provided his own... */ |
2135 | dm->dqb_btime = get_seconds() + dqi->dqi_bgrace; | 2371 | dm->dqb_btime = get_seconds() + dqi->dqi_bgrace; |
2136 | } | 2372 | } |
2137 | if (check_ilim) { | 2373 | if (check_ilim) { |
2138 | if (!dm->dqb_isoftlimit || dm->dqb_curinodes < dm->dqb_isoftlimit) { | 2374 | if (!dm->dqb_isoftlimit || |
2375 | dm->dqb_curinodes < dm->dqb_isoftlimit) { | ||
2139 | dm->dqb_itime = 0; | 2376 | dm->dqb_itime = 0; |
2140 | clear_bit(DQ_INODES_B, &dquot->dq_flags); | 2377 | clear_bit(DQ_INODES_B, &dquot->dq_flags); |
2141 | } | 2378 | } else if (!(di->dqb_valid & QIF_ITIME)) |
2142 | else if (!(di->dqb_valid & QIF_ITIME)) /* Set grace only if user hasn't provided his own... */ | 2379 | /* Set grace only if user hasn't provided his own... */ |
2143 | dm->dqb_itime = get_seconds() + dqi->dqi_igrace; | 2380 | dm->dqb_itime = get_seconds() + dqi->dqi_igrace; |
2144 | } | 2381 | } |
2145 | if (dm->dqb_bhardlimit || dm->dqb_bsoftlimit || dm->dqb_ihardlimit || dm->dqb_isoftlimit) | 2382 | if (dm->dqb_bhardlimit || dm->dqb_bsoftlimit || dm->dqb_ihardlimit || |
2383 | dm->dqb_isoftlimit) | ||
2146 | clear_bit(DQ_FAKE_B, &dquot->dq_flags); | 2384 | clear_bit(DQ_FAKE_B, &dquot->dq_flags); |
2147 | else | 2385 | else |
2148 | set_bit(DQ_FAKE_B, &dquot->dq_flags); | 2386 | set_bit(DQ_FAKE_B, &dquot->dq_flags); |
@@ -2152,7 +2390,8 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di) | |||
2152 | return 0; | 2390 | return 0; |
2153 | } | 2391 | } |
2154 | 2392 | ||
2155 | int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di) | 2393 | int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, |
2394 | struct if_dqblk *di) | ||
2156 | { | 2395 | { |
2157 | struct dquot *dquot; | 2396 | struct dquot *dquot; |
2158 | int rc; | 2397 | int rc; |
@@ -2167,6 +2406,7 @@ int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *d | |||
2167 | out: | 2406 | out: |
2168 | return rc; | 2407 | return rc; |
2169 | } | 2408 | } |
2409 | EXPORT_SYMBOL(vfs_set_dqblk); | ||
2170 | 2410 | ||
2171 | /* Generic routine for getting common part of quota file information */ | 2411 | /* Generic routine for getting common part of quota file information */ |
2172 | int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) | 2412 | int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) |
@@ -2188,6 +2428,7 @@ int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) | |||
2188 | mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); | 2428 | mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); |
2189 | return 0; | 2429 | return 0; |
2190 | } | 2430 | } |
2431 | EXPORT_SYMBOL(vfs_get_dqinfo); | ||
2191 | 2432 | ||
2192 | /* Generic routine for setting common part of quota file information */ | 2433 | /* Generic routine for setting common part of quota file information */ |
2193 | int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) | 2434 | int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) |
@@ -2207,7 +2448,8 @@ int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) | |||
2207 | if (ii->dqi_valid & IIF_IGRACE) | 2448 | if (ii->dqi_valid & IIF_IGRACE) |
2208 | mi->dqi_igrace = ii->dqi_igrace; | 2449 | mi->dqi_igrace = ii->dqi_igrace; |
2209 | if (ii->dqi_valid & IIF_FLAGS) | 2450 | if (ii->dqi_valid & IIF_FLAGS) |
2210 | mi->dqi_flags = (mi->dqi_flags & ~DQF_MASK) | (ii->dqi_flags & DQF_MASK); | 2451 | mi->dqi_flags = (mi->dqi_flags & ~DQF_MASK) | |
2452 | (ii->dqi_flags & DQF_MASK); | ||
2211 | spin_unlock(&dq_data_lock); | 2453 | spin_unlock(&dq_data_lock); |
2212 | mark_info_dirty(sb, type); | 2454 | mark_info_dirty(sb, type); |
2213 | /* Force write to disk */ | 2455 | /* Force write to disk */ |
@@ -2216,6 +2458,7 @@ out: | |||
2216 | mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); | 2458 | mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); |
2217 | return err; | 2459 | return err; |
2218 | } | 2460 | } |
2461 | EXPORT_SYMBOL(vfs_set_dqinfo); | ||
2219 | 2462 | ||
2220 | struct quotactl_ops vfs_quotactl_ops = { | 2463 | struct quotactl_ops vfs_quotactl_ops = { |
2221 | .quota_on = vfs_quota_on, | 2464 | .quota_on = vfs_quota_on, |
@@ -2365,43 +2608,10 @@ static int __init dquot_init(void) | |||
2365 | 2608 | ||
2366 | #ifdef CONFIG_QUOTA_NETLINK_INTERFACE | 2609 | #ifdef CONFIG_QUOTA_NETLINK_INTERFACE |
2367 | if (genl_register_family("a_genl_family) != 0) | 2610 | if (genl_register_family("a_genl_family) != 0) |
2368 | printk(KERN_ERR "VFS: Failed to create quota netlink interface.\n"); | 2611 | printk(KERN_ERR |
2612 | "VFS: Failed to create quota netlink interface.\n"); | ||
2369 | #endif | 2613 | #endif |
2370 | 2614 | ||
2371 | return 0; | 2615 | return 0; |
2372 | } | 2616 | } |
2373 | module_init(dquot_init); | 2617 | module_init(dquot_init); |
2374 | |||
2375 | EXPORT_SYMBOL(register_quota_format); | ||
2376 | EXPORT_SYMBOL(unregister_quota_format); | ||
2377 | EXPORT_SYMBOL(dqstats); | ||
2378 | EXPORT_SYMBOL(dq_data_lock); | ||
2379 | EXPORT_SYMBOL(vfs_quota_enable); | ||
2380 | EXPORT_SYMBOL(vfs_quota_on); | ||
2381 | EXPORT_SYMBOL(vfs_quota_on_path); | ||
2382 | EXPORT_SYMBOL(vfs_quota_on_mount); | ||
2383 | EXPORT_SYMBOL(vfs_quota_disable); | ||
2384 | EXPORT_SYMBOL(vfs_quota_off); | ||
2385 | EXPORT_SYMBOL(dquot_scan_active); | ||
2386 | EXPORT_SYMBOL(vfs_quota_sync); | ||
2387 | EXPORT_SYMBOL(vfs_get_dqinfo); | ||
2388 | EXPORT_SYMBOL(vfs_set_dqinfo); | ||
2389 | EXPORT_SYMBOL(vfs_get_dqblk); | ||
2390 | EXPORT_SYMBOL(vfs_set_dqblk); | ||
2391 | EXPORT_SYMBOL(dquot_commit); | ||
2392 | EXPORT_SYMBOL(dquot_commit_info); | ||
2393 | EXPORT_SYMBOL(dquot_acquire); | ||
2394 | EXPORT_SYMBOL(dquot_release); | ||
2395 | EXPORT_SYMBOL(dquot_mark_dquot_dirty); | ||
2396 | EXPORT_SYMBOL(dquot_initialize); | ||
2397 | EXPORT_SYMBOL(dquot_drop); | ||
2398 | EXPORT_SYMBOL(vfs_dq_drop); | ||
2399 | EXPORT_SYMBOL(dqget); | ||
2400 | EXPORT_SYMBOL(dqput); | ||
2401 | EXPORT_SYMBOL(dquot_alloc_space); | ||
2402 | EXPORT_SYMBOL(dquot_alloc_inode); | ||
2403 | EXPORT_SYMBOL(dquot_free_space); | ||
2404 | EXPORT_SYMBOL(dquot_free_inode); | ||
2405 | EXPORT_SYMBOL(dquot_transfer); | ||
2406 | EXPORT_SYMBOL(vfs_dq_transfer); | ||
2407 | EXPORT_SYMBOL(vfs_dq_quota_on_remount); | ||
diff --git a/fs/quota.c b/fs/quota/quota.c index d76ada914f98..b7f5a468f076 100644 --- a/fs/quota.c +++ b/fs/quota/quota.c | |||
@@ -20,7 +20,8 @@ | |||
20 | #include <linux/types.h> | 20 | #include <linux/types.h> |
21 | 21 | ||
22 | /* Check validity of generic quotactl commands */ | 22 | /* Check validity of generic quotactl commands */ |
23 | static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id) | 23 | static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, |
24 | qid_t id) | ||
24 | { | 25 | { |
25 | if (type >= MAXQUOTAS) | 26 | if (type >= MAXQUOTAS) |
26 | return -EINVAL; | 27 | return -EINVAL; |
@@ -72,7 +73,8 @@ static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid | |||
72 | case Q_SETINFO: | 73 | case Q_SETINFO: |
73 | case Q_SETQUOTA: | 74 | case Q_SETQUOTA: |
74 | case Q_GETQUOTA: | 75 | case Q_GETQUOTA: |
75 | /* This is just informative test so we are satisfied without a lock */ | 76 | /* This is just an informative test so we are satisfied |
77 | * without the lock */ | ||
76 | if (!sb_has_quota_active(sb, type)) | 78 | if (!sb_has_quota_active(sb, type)) |
77 | return -ESRCH; | 79 | return -ESRCH; |
78 | } | 80 | } |
@@ -92,7 +94,8 @@ static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid | |||
92 | } | 94 | } |
93 | 95 | ||
94 | /* Check validity of XFS Quota Manager commands */ | 96 | /* Check validity of XFS Quota Manager commands */ |
95 | static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id) | 97 | static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd, |
98 | qid_t id) | ||
96 | { | 99 | { |
97 | if (type >= XQM_MAXQUOTAS) | 100 | if (type >= XQM_MAXQUOTAS) |
98 | return -EINVAL; | 101 | return -EINVAL; |
@@ -142,7 +145,8 @@ static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t i | |||
142 | return 0; | 145 | return 0; |
143 | } | 146 | } |
144 | 147 | ||
145 | static int check_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id) | 148 | static int check_quotactl_valid(struct super_block *sb, int type, int cmd, |
149 | qid_t id) | ||
146 | { | 150 | { |
147 | int error; | 151 | int error; |
148 | 152 | ||
@@ -180,7 +184,8 @@ static void quota_sync_sb(struct super_block *sb, int type) | |||
180 | continue; | 184 | continue; |
181 | if (!sb_has_quota_active(sb, cnt)) | 185 | if (!sb_has_quota_active(sb, cnt)) |
182 | continue; | 186 | continue; |
183 | mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex, I_MUTEX_QUOTA); | 187 | mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex, |
188 | I_MUTEX_QUOTA); | ||
184 | truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0); | 189 | truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0); |
185 | mutex_unlock(&sb_dqopt(sb)->files[cnt]->i_mutex); | 190 | mutex_unlock(&sb_dqopt(sb)->files[cnt]->i_mutex); |
186 | } | 191 | } |
@@ -200,14 +205,15 @@ void sync_dquots(struct super_block *sb, int type) | |||
200 | spin_lock(&sb_lock); | 205 | spin_lock(&sb_lock); |
201 | restart: | 206 | restart: |
202 | list_for_each_entry(sb, &super_blocks, s_list) { | 207 | list_for_each_entry(sb, &super_blocks, s_list) { |
203 | /* This test just improves performance so it needn't be reliable... */ | 208 | /* This test just improves performance so it needn't be |
209 | * reliable... */ | ||
204 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 210 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
205 | if (type != -1 && type != cnt) | 211 | if (type != -1 && type != cnt) |
206 | continue; | 212 | continue; |
207 | if (!sb_has_quota_active(sb, cnt)) | 213 | if (!sb_has_quota_active(sb, cnt)) |
208 | continue; | 214 | continue; |
209 | if (!info_dirty(&sb_dqopt(sb)->info[cnt]) && | 215 | if (!info_dirty(&sb_dqopt(sb)->info[cnt]) && |
210 | list_empty(&sb_dqopt(sb)->info[cnt].dqi_dirty_list)) | 216 | list_empty(&sb_dqopt(sb)->info[cnt].dqi_dirty_list)) |
211 | continue; | 217 | continue; |
212 | break; | 218 | break; |
213 | } | 219 | } |
@@ -227,7 +233,8 @@ restart: | |||
227 | } | 233 | } |
228 | 234 | ||
229 | /* Copy parameters and call proper function */ | 235 | /* Copy parameters and call proper function */ |
230 | static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void __user *addr) | 236 | static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, |
237 | void __user *addr) | ||
231 | { | 238 | { |
232 | int ret; | 239 | int ret; |
233 | 240 | ||
@@ -235,7 +242,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void | |||
235 | case Q_QUOTAON: { | 242 | case Q_QUOTAON: { |
236 | char *pathname; | 243 | char *pathname; |
237 | 244 | ||
238 | if (IS_ERR(pathname = getname(addr))) | 245 | pathname = getname(addr); |
246 | if (IS_ERR(pathname)) | ||
239 | return PTR_ERR(pathname); | 247 | return PTR_ERR(pathname); |
240 | ret = sb->s_qcop->quota_on(sb, type, id, pathname, 0); | 248 | ret = sb->s_qcop->quota_on(sb, type, id, pathname, 0); |
241 | putname(pathname); | 249 | putname(pathname); |
@@ -261,7 +269,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void | |||
261 | case Q_GETINFO: { | 269 | case Q_GETINFO: { |
262 | struct if_dqinfo info; | 270 | struct if_dqinfo info; |
263 | 271 | ||
264 | if ((ret = sb->s_qcop->get_info(sb, type, &info))) | 272 | ret = sb->s_qcop->get_info(sb, type, &info); |
273 | if (ret) | ||
265 | return ret; | 274 | return ret; |
266 | if (copy_to_user(addr, &info, sizeof(info))) | 275 | if (copy_to_user(addr, &info, sizeof(info))) |
267 | return -EFAULT; | 276 | return -EFAULT; |
@@ -277,7 +286,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void | |||
277 | case Q_GETQUOTA: { | 286 | case Q_GETQUOTA: { |
278 | struct if_dqblk idq; | 287 | struct if_dqblk idq; |
279 | 288 | ||
280 | if ((ret = sb->s_qcop->get_dqblk(sb, type, id, &idq))) | 289 | ret = sb->s_qcop->get_dqblk(sb, type, id, &idq); |
290 | if (ret) | ||
281 | return ret; | 291 | return ret; |
282 | if (copy_to_user(addr, &idq, sizeof(idq))) | 292 | if (copy_to_user(addr, &idq, sizeof(idq))) |
283 | return -EFAULT; | 293 | return -EFAULT; |
@@ -322,7 +332,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void | |||
322 | case Q_XGETQUOTA: { | 332 | case Q_XGETQUOTA: { |
323 | struct fs_disk_quota fdq; | 333 | struct fs_disk_quota fdq; |
324 | 334 | ||
325 | if ((ret = sb->s_qcop->get_xquota(sb, type, id, &fdq))) | 335 | ret = sb->s_qcop->get_xquota(sb, type, id, &fdq); |
336 | if (ret) | ||
326 | return ret; | 337 | return ret; |
327 | if (copy_to_user(addr, &fdq, sizeof(fdq))) | 338 | if (copy_to_user(addr, &fdq, sizeof(fdq))) |
328 | return -EFAULT; | 339 | return -EFAULT; |
@@ -341,7 +352,7 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void | |||
341 | * look up a superblock on which quota ops will be performed | 352 | * look up a superblock on which quota ops will be performed |
342 | * - use the name of a block device to find the superblock thereon | 353 | * - use the name of a block device to find the superblock thereon |
343 | */ | 354 | */ |
344 | static inline struct super_block *quotactl_block(const char __user *special) | 355 | static struct super_block *quotactl_block(const char __user *special) |
345 | { | 356 | { |
346 | #ifdef CONFIG_BLOCK | 357 | #ifdef CONFIG_BLOCK |
347 | struct block_device *bdev; | 358 | struct block_device *bdev; |
diff --git a/fs/quota_tree.c b/fs/quota/quota_tree.c index 953404c95b17..f81f4bcfb178 100644 --- a/fs/quota_tree.c +++ b/fs/quota/quota_tree.c | |||
@@ -22,8 +22,6 @@ MODULE_LICENSE("GPL"); | |||
22 | 22 | ||
23 | #define __QUOTA_QT_PARANOIA | 23 | #define __QUOTA_QT_PARANOIA |
24 | 24 | ||
25 | typedef char *dqbuf_t; | ||
26 | |||
27 | static int get_index(struct qtree_mem_dqinfo *info, qid_t id, int depth) | 25 | static int get_index(struct qtree_mem_dqinfo *info, qid_t id, int depth) |
28 | { | 26 | { |
29 | unsigned int epb = info->dqi_usable_bs >> 2; | 27 | unsigned int epb = info->dqi_usable_bs >> 2; |
@@ -35,46 +33,42 @@ static int get_index(struct qtree_mem_dqinfo *info, qid_t id, int depth) | |||
35 | } | 33 | } |
36 | 34 | ||
37 | /* Number of entries in one blocks */ | 35 | /* Number of entries in one blocks */ |
38 | static inline int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info) | 36 | static int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info) |
39 | { | 37 | { |
40 | return (info->dqi_usable_bs - sizeof(struct qt_disk_dqdbheader)) | 38 | return (info->dqi_usable_bs - sizeof(struct qt_disk_dqdbheader)) |
41 | / info->dqi_entry_size; | 39 | / info->dqi_entry_size; |
42 | } | 40 | } |
43 | 41 | ||
44 | static dqbuf_t getdqbuf(size_t size) | 42 | static char *getdqbuf(size_t size) |
45 | { | 43 | { |
46 | dqbuf_t buf = kmalloc(size, GFP_NOFS); | 44 | char *buf = kmalloc(size, GFP_NOFS); |
47 | if (!buf) | 45 | if (!buf) |
48 | printk(KERN_WARNING "VFS: Not enough memory for quota buffers.\n"); | 46 | printk(KERN_WARNING |
47 | "VFS: Not enough memory for quota buffers.\n"); | ||
49 | return buf; | 48 | return buf; |
50 | } | 49 | } |
51 | 50 | ||
52 | static inline void freedqbuf(dqbuf_t buf) | 51 | static ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf) |
53 | { | ||
54 | kfree(buf); | ||
55 | } | ||
56 | |||
57 | static inline ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, dqbuf_t buf) | ||
58 | { | 52 | { |
59 | struct super_block *sb = info->dqi_sb; | 53 | struct super_block *sb = info->dqi_sb; |
60 | 54 | ||
61 | memset(buf, 0, info->dqi_usable_bs); | 55 | memset(buf, 0, info->dqi_usable_bs); |
62 | return sb->s_op->quota_read(sb, info->dqi_type, (char *)buf, | 56 | return sb->s_op->quota_read(sb, info->dqi_type, buf, |
63 | info->dqi_usable_bs, blk << info->dqi_blocksize_bits); | 57 | info->dqi_usable_bs, blk << info->dqi_blocksize_bits); |
64 | } | 58 | } |
65 | 59 | ||
66 | static inline ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, dqbuf_t buf) | 60 | static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf) |
67 | { | 61 | { |
68 | struct super_block *sb = info->dqi_sb; | 62 | struct super_block *sb = info->dqi_sb; |
69 | 63 | ||
70 | return sb->s_op->quota_write(sb, info->dqi_type, (char *)buf, | 64 | return sb->s_op->quota_write(sb, info->dqi_type, buf, |
71 | info->dqi_usable_bs, blk << info->dqi_blocksize_bits); | 65 | info->dqi_usable_bs, blk << info->dqi_blocksize_bits); |
72 | } | 66 | } |
73 | 67 | ||
74 | /* Remove empty block from list and return it */ | 68 | /* Remove empty block from list and return it */ |
75 | static int get_free_dqblk(struct qtree_mem_dqinfo *info) | 69 | static int get_free_dqblk(struct qtree_mem_dqinfo *info) |
76 | { | 70 | { |
77 | dqbuf_t buf = getdqbuf(info->dqi_usable_bs); | 71 | char *buf = getdqbuf(info->dqi_usable_bs); |
78 | struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; | 72 | struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; |
79 | int ret, blk; | 73 | int ret, blk; |
80 | 74 | ||
@@ -98,12 +92,12 @@ static int get_free_dqblk(struct qtree_mem_dqinfo *info) | |||
98 | mark_info_dirty(info->dqi_sb, info->dqi_type); | 92 | mark_info_dirty(info->dqi_sb, info->dqi_type); |
99 | ret = blk; | 93 | ret = blk; |
100 | out_buf: | 94 | out_buf: |
101 | freedqbuf(buf); | 95 | kfree(buf); |
102 | return ret; | 96 | return ret; |
103 | } | 97 | } |
104 | 98 | ||
105 | /* Insert empty block to the list */ | 99 | /* Insert empty block to the list */ |
106 | static int put_free_dqblk(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint blk) | 100 | static int put_free_dqblk(struct qtree_mem_dqinfo *info, char *buf, uint blk) |
107 | { | 101 | { |
108 | struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; | 102 | struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; |
109 | int err; | 103 | int err; |
@@ -120,9 +114,10 @@ static int put_free_dqblk(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint blk) | |||
120 | } | 114 | } |
121 | 115 | ||
122 | /* Remove given block from the list of blocks with free entries */ | 116 | /* Remove given block from the list of blocks with free entries */ |
123 | static int remove_free_dqentry(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint blk) | 117 | static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, |
118 | uint blk) | ||
124 | { | 119 | { |
125 | dqbuf_t tmpbuf = getdqbuf(info->dqi_usable_bs); | 120 | char *tmpbuf = getdqbuf(info->dqi_usable_bs); |
126 | struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; | 121 | struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; |
127 | uint nextblk = le32_to_cpu(dh->dqdh_next_free); | 122 | uint nextblk = le32_to_cpu(dh->dqdh_next_free); |
128 | uint prevblk = le32_to_cpu(dh->dqdh_prev_free); | 123 | uint prevblk = le32_to_cpu(dh->dqdh_prev_free); |
@@ -153,21 +148,24 @@ static int remove_free_dqentry(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint | |||
153 | info->dqi_free_entry = nextblk; | 148 | info->dqi_free_entry = nextblk; |
154 | mark_info_dirty(info->dqi_sb, info->dqi_type); | 149 | mark_info_dirty(info->dqi_sb, info->dqi_type); |
155 | } | 150 | } |
156 | freedqbuf(tmpbuf); | 151 | kfree(tmpbuf); |
157 | dh->dqdh_next_free = dh->dqdh_prev_free = cpu_to_le32(0); | 152 | dh->dqdh_next_free = dh->dqdh_prev_free = cpu_to_le32(0); |
158 | /* No matter whether write succeeds block is out of list */ | 153 | /* No matter whether write succeeds block is out of list */ |
159 | if (write_blk(info, blk, buf) < 0) | 154 | if (write_blk(info, blk, buf) < 0) |
160 | printk(KERN_ERR "VFS: Can't write block (%u) with free entries.\n", blk); | 155 | printk(KERN_ERR |
156 | "VFS: Can't write block (%u) with free entries.\n", | ||
157 | blk); | ||
161 | return 0; | 158 | return 0; |
162 | out_buf: | 159 | out_buf: |
163 | freedqbuf(tmpbuf); | 160 | kfree(tmpbuf); |
164 | return err; | 161 | return err; |
165 | } | 162 | } |
166 | 163 | ||
167 | /* Insert given block to the beginning of list with free entries */ | 164 | /* Insert given block to the beginning of list with free entries */ |
168 | static int insert_free_dqentry(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint blk) | 165 | static int insert_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, |
166 | uint blk) | ||
169 | { | 167 | { |
170 | dqbuf_t tmpbuf = getdqbuf(info->dqi_usable_bs); | 168 | char *tmpbuf = getdqbuf(info->dqi_usable_bs); |
171 | struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; | 169 | struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; |
172 | int err; | 170 | int err; |
173 | 171 | ||
@@ -188,12 +186,12 @@ static int insert_free_dqentry(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint | |||
188 | if (err < 0) | 186 | if (err < 0) |
189 | goto out_buf; | 187 | goto out_buf; |
190 | } | 188 | } |
191 | freedqbuf(tmpbuf); | 189 | kfree(tmpbuf); |
192 | info->dqi_free_entry = blk; | 190 | info->dqi_free_entry = blk; |
193 | mark_info_dirty(info->dqi_sb, info->dqi_type); | 191 | mark_info_dirty(info->dqi_sb, info->dqi_type); |
194 | return 0; | 192 | return 0; |
195 | out_buf: | 193 | out_buf: |
196 | freedqbuf(tmpbuf); | 194 | kfree(tmpbuf); |
197 | return err; | 195 | return err; |
198 | } | 196 | } |
199 | 197 | ||
@@ -215,7 +213,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info, | |||
215 | { | 213 | { |
216 | uint blk, i; | 214 | uint blk, i; |
217 | struct qt_disk_dqdbheader *dh; | 215 | struct qt_disk_dqdbheader *dh; |
218 | dqbuf_t buf = getdqbuf(info->dqi_usable_bs); | 216 | char *buf = getdqbuf(info->dqi_usable_bs); |
219 | char *ddquot; | 217 | char *ddquot; |
220 | 218 | ||
221 | *err = 0; | 219 | *err = 0; |
@@ -233,11 +231,12 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info, | |||
233 | blk = get_free_dqblk(info); | 231 | blk = get_free_dqblk(info); |
234 | if ((int)blk < 0) { | 232 | if ((int)blk < 0) { |
235 | *err = blk; | 233 | *err = blk; |
236 | freedqbuf(buf); | 234 | kfree(buf); |
237 | return 0; | 235 | return 0; |
238 | } | 236 | } |
239 | memset(buf, 0, info->dqi_usable_bs); | 237 | memset(buf, 0, info->dqi_usable_bs); |
240 | /* This is enough as block is already zeroed and entry list is empty... */ | 238 | /* This is enough as the block is already zeroed and the entry |
239 | * list is empty... */ | ||
241 | info->dqi_free_entry = blk; | 240 | info->dqi_free_entry = blk; |
242 | mark_info_dirty(dquot->dq_sb, dquot->dq_type); | 241 | mark_info_dirty(dquot->dq_sb, dquot->dq_type); |
243 | } | 242 | } |
@@ -253,9 +252,12 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info, | |||
253 | } | 252 | } |
254 | le16_add_cpu(&dh->dqdh_entries, 1); | 253 | le16_add_cpu(&dh->dqdh_entries, 1); |
255 | /* Find free structure in block */ | 254 | /* Find free structure in block */ |
256 | for (i = 0, ddquot = ((char *)buf) + sizeof(struct qt_disk_dqdbheader); | 255 | ddquot = buf + sizeof(struct qt_disk_dqdbheader); |
257 | i < qtree_dqstr_in_blk(info) && !qtree_entry_unused(info, ddquot); | 256 | for (i = 0; i < qtree_dqstr_in_blk(info); i++) { |
258 | i++, ddquot += info->dqi_entry_size); | 257 | if (qtree_entry_unused(info, ddquot)) |
258 | break; | ||
259 | ddquot += info->dqi_entry_size; | ||
260 | } | ||
259 | #ifdef __QUOTA_QT_PARANOIA | 261 | #ifdef __QUOTA_QT_PARANOIA |
260 | if (i == qtree_dqstr_in_blk(info)) { | 262 | if (i == qtree_dqstr_in_blk(info)) { |
261 | printk(KERN_ERR "VFS: find_free_dqentry(): Data block full " | 263 | printk(KERN_ERR "VFS: find_free_dqentry(): Data block full " |
@@ -273,10 +275,10 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info, | |||
273 | dquot->dq_off = (blk << info->dqi_blocksize_bits) + | 275 | dquot->dq_off = (blk << info->dqi_blocksize_bits) + |
274 | sizeof(struct qt_disk_dqdbheader) + | 276 | sizeof(struct qt_disk_dqdbheader) + |
275 | i * info->dqi_entry_size; | 277 | i * info->dqi_entry_size; |
276 | freedqbuf(buf); | 278 | kfree(buf); |
277 | return blk; | 279 | return blk; |
278 | out_buf: | 280 | out_buf: |
279 | freedqbuf(buf); | 281 | kfree(buf); |
280 | return 0; | 282 | return 0; |
281 | } | 283 | } |
282 | 284 | ||
@@ -284,7 +286,7 @@ out_buf: | |||
284 | static int do_insert_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, | 286 | static int do_insert_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, |
285 | uint *treeblk, int depth) | 287 | uint *treeblk, int depth) |
286 | { | 288 | { |
287 | dqbuf_t buf = getdqbuf(info->dqi_usable_bs); | 289 | char *buf = getdqbuf(info->dqi_usable_bs); |
288 | int ret = 0, newson = 0, newact = 0; | 290 | int ret = 0, newson = 0, newact = 0; |
289 | __le32 *ref; | 291 | __le32 *ref; |
290 | uint newblk; | 292 | uint newblk; |
@@ -333,7 +335,7 @@ static int do_insert_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
333 | put_free_dqblk(info, buf, *treeblk); | 335 | put_free_dqblk(info, buf, *treeblk); |
334 | } | 336 | } |
335 | out_buf: | 337 | out_buf: |
336 | freedqbuf(buf); | 338 | kfree(buf); |
337 | return ret; | 339 | return ret; |
338 | } | 340 | } |
339 | 341 | ||
@@ -346,14 +348,15 @@ static inline int dq_insert_tree(struct qtree_mem_dqinfo *info, | |||
346 | } | 348 | } |
347 | 349 | ||
348 | /* | 350 | /* |
349 | * We don't have to be afraid of deadlocks as we never have quotas on quota files... | 351 | * We don't have to be afraid of deadlocks as we never have quotas on quota |
352 | * files... | ||
350 | */ | 353 | */ |
351 | int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | 354 | int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) |
352 | { | 355 | { |
353 | int type = dquot->dq_type; | 356 | int type = dquot->dq_type; |
354 | struct super_block *sb = dquot->dq_sb; | 357 | struct super_block *sb = dquot->dq_sb; |
355 | ssize_t ret; | 358 | ssize_t ret; |
356 | dqbuf_t ddquot = getdqbuf(info->dqi_entry_size); | 359 | char *ddquot = getdqbuf(info->dqi_entry_size); |
357 | 360 | ||
358 | if (!ddquot) | 361 | if (!ddquot) |
359 | return -ENOMEM; | 362 | return -ENOMEM; |
@@ -364,15 +367,15 @@ int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | |||
364 | if (ret < 0) { | 367 | if (ret < 0) { |
365 | printk(KERN_ERR "VFS: Error %zd occurred while " | 368 | printk(KERN_ERR "VFS: Error %zd occurred while " |
366 | "creating quota.\n", ret); | 369 | "creating quota.\n", ret); |
367 | freedqbuf(ddquot); | 370 | kfree(ddquot); |
368 | return ret; | 371 | return ret; |
369 | } | 372 | } |
370 | } | 373 | } |
371 | spin_lock(&dq_data_lock); | 374 | spin_lock(&dq_data_lock); |
372 | info->dqi_ops->mem2disk_dqblk(ddquot, dquot); | 375 | info->dqi_ops->mem2disk_dqblk(ddquot, dquot); |
373 | spin_unlock(&dq_data_lock); | 376 | spin_unlock(&dq_data_lock); |
374 | ret = sb->s_op->quota_write(sb, type, (char *)ddquot, | 377 | ret = sb->s_op->quota_write(sb, type, ddquot, info->dqi_entry_size, |
375 | info->dqi_entry_size, dquot->dq_off); | 378 | dquot->dq_off); |
376 | if (ret != info->dqi_entry_size) { | 379 | if (ret != info->dqi_entry_size) { |
377 | printk(KERN_WARNING "VFS: dquota write failed on dev %s\n", | 380 | printk(KERN_WARNING "VFS: dquota write failed on dev %s\n", |
378 | sb->s_id); | 381 | sb->s_id); |
@@ -382,7 +385,7 @@ int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | |||
382 | ret = 0; | 385 | ret = 0; |
383 | } | 386 | } |
384 | dqstats.writes++; | 387 | dqstats.writes++; |
385 | freedqbuf(ddquot); | 388 | kfree(ddquot); |
386 | 389 | ||
387 | return ret; | 390 | return ret; |
388 | } | 391 | } |
@@ -393,7 +396,7 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
393 | uint blk) | 396 | uint blk) |
394 | { | 397 | { |
395 | struct qt_disk_dqdbheader *dh; | 398 | struct qt_disk_dqdbheader *dh; |
396 | dqbuf_t buf = getdqbuf(info->dqi_usable_bs); | 399 | char *buf = getdqbuf(info->dqi_usable_bs); |
397 | int ret = 0; | 400 | int ret = 0; |
398 | 401 | ||
399 | if (!buf) | 402 | if (!buf) |
@@ -444,7 +447,7 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
444 | } | 447 | } |
445 | dquot->dq_off = 0; /* Quota is now unattached */ | 448 | dquot->dq_off = 0; /* Quota is now unattached */ |
446 | out_buf: | 449 | out_buf: |
447 | freedqbuf(buf); | 450 | kfree(buf); |
448 | return ret; | 451 | return ret; |
449 | } | 452 | } |
450 | 453 | ||
@@ -452,7 +455,7 @@ out_buf: | |||
452 | static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, | 455 | static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, |
453 | uint *blk, int depth) | 456 | uint *blk, int depth) |
454 | { | 457 | { |
455 | dqbuf_t buf = getdqbuf(info->dqi_usable_bs); | 458 | char *buf = getdqbuf(info->dqi_usable_bs); |
456 | int ret = 0; | 459 | int ret = 0; |
457 | uint newblk; | 460 | uint newblk; |
458 | __le32 *ref = (__le32 *)buf; | 461 | __le32 *ref = (__le32 *)buf; |
@@ -475,9 +478,8 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
475 | int i; | 478 | int i; |
476 | ref[get_index(info, dquot->dq_id, depth)] = cpu_to_le32(0); | 479 | ref[get_index(info, dquot->dq_id, depth)] = cpu_to_le32(0); |
477 | /* Block got empty? */ | 480 | /* Block got empty? */ |
478 | for (i = 0; | 481 | for (i = 0; i < (info->dqi_usable_bs >> 2) && !ref[i]; i++) |
479 | i < (info->dqi_usable_bs >> 2) && !ref[i]; | 482 | ; |
480 | i++); | ||
481 | /* Don't put the root block into the free block list */ | 483 | /* Don't put the root block into the free block list */ |
482 | if (i == (info->dqi_usable_bs >> 2) | 484 | if (i == (info->dqi_usable_bs >> 2) |
483 | && *blk != QT_TREEOFF) { | 485 | && *blk != QT_TREEOFF) { |
@@ -491,7 +493,7 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, | |||
491 | } | 493 | } |
492 | } | 494 | } |
493 | out_buf: | 495 | out_buf: |
494 | freedqbuf(buf); | 496 | kfree(buf); |
495 | return ret; | 497 | return ret; |
496 | } | 498 | } |
497 | 499 | ||
@@ -510,7 +512,7 @@ EXPORT_SYMBOL(qtree_delete_dquot); | |||
510 | static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info, | 512 | static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info, |
511 | struct dquot *dquot, uint blk) | 513 | struct dquot *dquot, uint blk) |
512 | { | 514 | { |
513 | dqbuf_t buf = getdqbuf(info->dqi_usable_bs); | 515 | char *buf = getdqbuf(info->dqi_usable_bs); |
514 | loff_t ret = 0; | 516 | loff_t ret = 0; |
515 | int i; | 517 | int i; |
516 | char *ddquot; | 518 | char *ddquot; |
@@ -522,9 +524,12 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info, | |||
522 | printk(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk); | 524 | printk(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk); |
523 | goto out_buf; | 525 | goto out_buf; |
524 | } | 526 | } |
525 | for (i = 0, ddquot = ((char *)buf) + sizeof(struct qt_disk_dqdbheader); | 527 | ddquot = buf + sizeof(struct qt_disk_dqdbheader); |
526 | i < qtree_dqstr_in_blk(info) && !info->dqi_ops->is_id(ddquot, dquot); | 528 | for (i = 0; i < qtree_dqstr_in_blk(info); i++) { |
527 | i++, ddquot += info->dqi_entry_size); | 529 | if (info->dqi_ops->is_id(ddquot, dquot)) |
530 | break; | ||
531 | ddquot += info->dqi_entry_size; | ||
532 | } | ||
528 | if (i == qtree_dqstr_in_blk(info)) { | 533 | if (i == qtree_dqstr_in_blk(info)) { |
529 | printk(KERN_ERR "VFS: Quota for id %u referenced " | 534 | printk(KERN_ERR "VFS: Quota for id %u referenced " |
530 | "but not present.\n", dquot->dq_id); | 535 | "but not present.\n", dquot->dq_id); |
@@ -535,7 +540,7 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info, | |||
535 | qt_disk_dqdbheader) + i * info->dqi_entry_size; | 540 | qt_disk_dqdbheader) + i * info->dqi_entry_size; |
536 | } | 541 | } |
537 | out_buf: | 542 | out_buf: |
538 | freedqbuf(buf); | 543 | kfree(buf); |
539 | return ret; | 544 | return ret; |
540 | } | 545 | } |
541 | 546 | ||
@@ -543,7 +548,7 @@ out_buf: | |||
543 | static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info, | 548 | static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info, |
544 | struct dquot *dquot, uint blk, int depth) | 549 | struct dquot *dquot, uint blk, int depth) |
545 | { | 550 | { |
546 | dqbuf_t buf = getdqbuf(info->dqi_usable_bs); | 551 | char *buf = getdqbuf(info->dqi_usable_bs); |
547 | loff_t ret = 0; | 552 | loff_t ret = 0; |
548 | __le32 *ref = (__le32 *)buf; | 553 | __le32 *ref = (__le32 *)buf; |
549 | 554 | ||
@@ -563,7 +568,7 @@ static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info, | |||
563 | else | 568 | else |
564 | ret = find_block_dqentry(info, dquot, blk); | 569 | ret = find_block_dqentry(info, dquot, blk); |
565 | out_buf: | 570 | out_buf: |
566 | freedqbuf(buf); | 571 | kfree(buf); |
567 | return ret; | 572 | return ret; |
568 | } | 573 | } |
569 | 574 | ||
@@ -579,7 +584,7 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | |||
579 | int type = dquot->dq_type; | 584 | int type = dquot->dq_type; |
580 | struct super_block *sb = dquot->dq_sb; | 585 | struct super_block *sb = dquot->dq_sb; |
581 | loff_t offset; | 586 | loff_t offset; |
582 | dqbuf_t ddquot; | 587 | char *ddquot; |
583 | int ret = 0; | 588 | int ret = 0; |
584 | 589 | ||
585 | #ifdef __QUOTA_QT_PARANOIA | 590 | #ifdef __QUOTA_QT_PARANOIA |
@@ -607,8 +612,8 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | |||
607 | ddquot = getdqbuf(info->dqi_entry_size); | 612 | ddquot = getdqbuf(info->dqi_entry_size); |
608 | if (!ddquot) | 613 | if (!ddquot) |
609 | return -ENOMEM; | 614 | return -ENOMEM; |
610 | ret = sb->s_op->quota_read(sb, type, (char *)ddquot, | 615 | ret = sb->s_op->quota_read(sb, type, ddquot, info->dqi_entry_size, |
611 | info->dqi_entry_size, dquot->dq_off); | 616 | dquot->dq_off); |
612 | if (ret != info->dqi_entry_size) { | 617 | if (ret != info->dqi_entry_size) { |
613 | if (ret >= 0) | 618 | if (ret >= 0) |
614 | ret = -EIO; | 619 | ret = -EIO; |
@@ -616,7 +621,7 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | |||
616 | "structure for id %u.\n", dquot->dq_id); | 621 | "structure for id %u.\n", dquot->dq_id); |
617 | set_bit(DQ_FAKE_B, &dquot->dq_flags); | 622 | set_bit(DQ_FAKE_B, &dquot->dq_flags); |
618 | memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk)); | 623 | memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk)); |
619 | freedqbuf(ddquot); | 624 | kfree(ddquot); |
620 | goto out; | 625 | goto out; |
621 | } | 626 | } |
622 | spin_lock(&dq_data_lock); | 627 | spin_lock(&dq_data_lock); |
@@ -627,7 +632,7 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | |||
627 | !dquot->dq_dqb.dqb_isoftlimit) | 632 | !dquot->dq_dqb.dqb_isoftlimit) |
628 | set_bit(DQ_FAKE_B, &dquot->dq_flags); | 633 | set_bit(DQ_FAKE_B, &dquot->dq_flags); |
629 | spin_unlock(&dq_data_lock); | 634 | spin_unlock(&dq_data_lock); |
630 | freedqbuf(ddquot); | 635 | kfree(ddquot); |
631 | out: | 636 | out: |
632 | dqstats.reads++; | 637 | dqstats.reads++; |
633 | return ret; | 638 | return ret; |
@@ -638,7 +643,8 @@ EXPORT_SYMBOL(qtree_read_dquot); | |||
638 | * the only one operating on dquot (thanks to dq_lock) */ | 643 | * the only one operating on dquot (thanks to dq_lock) */ |
639 | int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) | 644 | int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) |
640 | { | 645 | { |
641 | if (test_bit(DQ_FAKE_B, &dquot->dq_flags) && !(dquot->dq_dqb.dqb_curinodes | dquot->dq_dqb.dqb_curspace)) | 646 | if (test_bit(DQ_FAKE_B, &dquot->dq_flags) && |
647 | !(dquot->dq_dqb.dqb_curinodes | dquot->dq_dqb.dqb_curspace)) | ||
642 | return qtree_delete_dquot(info, dquot); | 648 | return qtree_delete_dquot(info, dquot); |
643 | return 0; | 649 | return 0; |
644 | } | 650 | } |
diff --git a/fs/quota_tree.h b/fs/quota/quota_tree.h index a1ab8db81a51..a1ab8db81a51 100644 --- a/fs/quota_tree.h +++ b/fs/quota/quota_tree.h | |||
diff --git a/fs/quota_v1.c b/fs/quota/quota_v1.c index b4af1c69ad16..0edcf42b1778 100644 --- a/fs/quota_v1.c +++ b/fs/quota/quota_v1.c | |||
@@ -62,11 +62,14 @@ static int v1_read_dqblk(struct dquot *dquot) | |||
62 | 62 | ||
63 | /* Set structure to 0s in case read fails/is after end of file */ | 63 | /* Set structure to 0s in case read fails/is after end of file */ |
64 | memset(&dqblk, 0, sizeof(struct v1_disk_dqblk)); | 64 | memset(&dqblk, 0, sizeof(struct v1_disk_dqblk)); |
65 | dquot->dq_sb->s_op->quota_read(dquot->dq_sb, type, (char *)&dqblk, sizeof(struct v1_disk_dqblk), v1_dqoff(dquot->dq_id)); | 65 | dquot->dq_sb->s_op->quota_read(dquot->dq_sb, type, (char *)&dqblk, |
66 | sizeof(struct v1_disk_dqblk), v1_dqoff(dquot->dq_id)); | ||
66 | 67 | ||
67 | v1_disk2mem_dqblk(&dquot->dq_dqb, &dqblk); | 68 | v1_disk2mem_dqblk(&dquot->dq_dqb, &dqblk); |
68 | if (dquot->dq_dqb.dqb_bhardlimit == 0 && dquot->dq_dqb.dqb_bsoftlimit == 0 && | 69 | if (dquot->dq_dqb.dqb_bhardlimit == 0 && |
69 | dquot->dq_dqb.dqb_ihardlimit == 0 && dquot->dq_dqb.dqb_isoftlimit == 0) | 70 | dquot->dq_dqb.dqb_bsoftlimit == 0 && |
71 | dquot->dq_dqb.dqb_ihardlimit == 0 && | ||
72 | dquot->dq_dqb.dqb_isoftlimit == 0) | ||
70 | set_bit(DQ_FAKE_B, &dquot->dq_flags); | 73 | set_bit(DQ_FAKE_B, &dquot->dq_flags); |
71 | dqstats.reads++; | 74 | dqstats.reads++; |
72 | 75 | ||
@@ -81,13 +84,16 @@ static int v1_commit_dqblk(struct dquot *dquot) | |||
81 | 84 | ||
82 | v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb); | 85 | v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb); |
83 | if (dquot->dq_id == 0) { | 86 | if (dquot->dq_id == 0) { |
84 | dqblk.dqb_btime = sb_dqopt(dquot->dq_sb)->info[type].dqi_bgrace; | 87 | dqblk.dqb_btime = |
85 | dqblk.dqb_itime = sb_dqopt(dquot->dq_sb)->info[type].dqi_igrace; | 88 | sb_dqopt(dquot->dq_sb)->info[type].dqi_bgrace; |
89 | dqblk.dqb_itime = | ||
90 | sb_dqopt(dquot->dq_sb)->info[type].dqi_igrace; | ||
86 | } | 91 | } |
87 | ret = 0; | 92 | ret = 0; |
88 | if (sb_dqopt(dquot->dq_sb)->files[type]) | 93 | if (sb_dqopt(dquot->dq_sb)->files[type]) |
89 | ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type, (char *)&dqblk, | 94 | ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type, |
90 | sizeof(struct v1_disk_dqblk), v1_dqoff(dquot->dq_id)); | 95 | (char *)&dqblk, sizeof(struct v1_disk_dqblk), |
96 | v1_dqoff(dquot->dq_id)); | ||
91 | if (ret != sizeof(struct v1_disk_dqblk)) { | 97 | if (ret != sizeof(struct v1_disk_dqblk)) { |
92 | printk(KERN_WARNING "VFS: dquota write failed on dev %s\n", | 98 | printk(KERN_WARNING "VFS: dquota write failed on dev %s\n", |
93 | dquot->dq_sb->s_id); | 99 | dquot->dq_sb->s_id); |
@@ -130,15 +136,20 @@ static int v1_check_quota_file(struct super_block *sb, int type) | |||
130 | return 0; | 136 | return 0; |
131 | blocks = isize >> BLOCK_SIZE_BITS; | 137 | blocks = isize >> BLOCK_SIZE_BITS; |
132 | off = isize & (BLOCK_SIZE - 1); | 138 | off = isize & (BLOCK_SIZE - 1); |
133 | if ((blocks % sizeof(struct v1_disk_dqblk) * BLOCK_SIZE + off) % sizeof(struct v1_disk_dqblk)) | 139 | if ((blocks % sizeof(struct v1_disk_dqblk) * BLOCK_SIZE + off) % |
140 | sizeof(struct v1_disk_dqblk)) | ||
134 | return 0; | 141 | return 0; |
135 | /* Doublecheck whether we didn't get file with new format - with old quotactl() this could happen */ | 142 | /* Doublecheck whether we didn't get file with new format - with old |
136 | size = sb->s_op->quota_read(sb, type, (char *)&dqhead, sizeof(struct v2_disk_dqheader), 0); | 143 | * quotactl() this could happen */ |
144 | size = sb->s_op->quota_read(sb, type, (char *)&dqhead, | ||
145 | sizeof(struct v2_disk_dqheader), 0); | ||
137 | if (size != sizeof(struct v2_disk_dqheader)) | 146 | if (size != sizeof(struct v2_disk_dqheader)) |
138 | return 1; /* Probably not new format */ | 147 | return 1; /* Probably not new format */ |
139 | if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type]) | 148 | if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type]) |
140 | return 1; /* Definitely not new format */ | 149 | return 1; /* Definitely not new format */ |
141 | printk(KERN_INFO "VFS: %s: Refusing to turn on old quota format on given file. It probably contains newer quota format.\n", sb->s_id); | 150 | printk(KERN_INFO |
151 | "VFS: %s: Refusing to turn on old quota format on given file." | ||
152 | " It probably contains newer quota format.\n", sb->s_id); | ||
142 | return 0; /* Seems like a new format file -> refuse it */ | 153 | return 0; /* Seems like a new format file -> refuse it */ |
143 | } | 154 | } |
144 | 155 | ||
@@ -148,7 +159,9 @@ static int v1_read_file_info(struct super_block *sb, int type) | |||
148 | struct v1_disk_dqblk dqblk; | 159 | struct v1_disk_dqblk dqblk; |
149 | int ret; | 160 | int ret; |
150 | 161 | ||
151 | if ((ret = sb->s_op->quota_read(sb, type, (char *)&dqblk, sizeof(struct v1_disk_dqblk), v1_dqoff(0))) != sizeof(struct v1_disk_dqblk)) { | 162 | ret = sb->s_op->quota_read(sb, type, (char *)&dqblk, |
163 | sizeof(struct v1_disk_dqblk), v1_dqoff(0)); | ||
164 | if (ret != sizeof(struct v1_disk_dqblk)) { | ||
152 | if (ret >= 0) | 165 | if (ret >= 0) |
153 | ret = -EIO; | 166 | ret = -EIO; |
154 | goto out; | 167 | goto out; |
@@ -157,8 +170,10 @@ static int v1_read_file_info(struct super_block *sb, int type) | |||
157 | /* limits are stored as unsigned 32-bit data */ | 170 | /* limits are stored as unsigned 32-bit data */ |
158 | dqopt->info[type].dqi_maxblimit = 0xffffffff; | 171 | dqopt->info[type].dqi_maxblimit = 0xffffffff; |
159 | dqopt->info[type].dqi_maxilimit = 0xffffffff; | 172 | dqopt->info[type].dqi_maxilimit = 0xffffffff; |
160 | dqopt->info[type].dqi_igrace = dqblk.dqb_itime ? dqblk.dqb_itime : MAX_IQ_TIME; | 173 | dqopt->info[type].dqi_igrace = |
161 | dqopt->info[type].dqi_bgrace = dqblk.dqb_btime ? dqblk.dqb_btime : MAX_DQ_TIME; | 174 | dqblk.dqb_itime ? dqblk.dqb_itime : MAX_IQ_TIME; |
175 | dqopt->info[type].dqi_bgrace = | ||
176 | dqblk.dqb_btime ? dqblk.dqb_btime : MAX_DQ_TIME; | ||
162 | out: | 177 | out: |
163 | return ret; | 178 | return ret; |
164 | } | 179 | } |
@@ -170,8 +185,9 @@ static int v1_write_file_info(struct super_block *sb, int type) | |||
170 | int ret; | 185 | int ret; |
171 | 186 | ||
172 | dqopt->info[type].dqi_flags &= ~DQF_INFO_DIRTY; | 187 | dqopt->info[type].dqi_flags &= ~DQF_INFO_DIRTY; |
173 | if ((ret = sb->s_op->quota_read(sb, type, (char *)&dqblk, | 188 | ret = sb->s_op->quota_read(sb, type, (char *)&dqblk, |
174 | sizeof(struct v1_disk_dqblk), v1_dqoff(0))) != sizeof(struct v1_disk_dqblk)) { | 189 | sizeof(struct v1_disk_dqblk), v1_dqoff(0)); |
190 | if (ret != sizeof(struct v1_disk_dqblk)) { | ||
175 | if (ret >= 0) | 191 | if (ret >= 0) |
176 | ret = -EIO; | 192 | ret = -EIO; |
177 | goto out; | 193 | goto out; |
diff --git a/fs/quota_v2.c b/fs/quota/quota_v2.c index b618b563635c..a5475fb1ae44 100644 --- a/fs/quota_v2.c +++ b/fs/quota/quota_v2.c | |||
@@ -54,7 +54,8 @@ static int v2_check_quota_file(struct super_block *sb, int type) | |||
54 | static const uint quota_magics[] = V2_INITQMAGICS; | 54 | static const uint quota_magics[] = V2_INITQMAGICS; |
55 | static const uint quota_versions[] = V2_INITQVERSIONS; | 55 | static const uint quota_versions[] = V2_INITQVERSIONS; |
56 | 56 | ||
57 | size = sb->s_op->quota_read(sb, type, (char *)&dqhead, sizeof(struct v2_disk_dqheader), 0); | 57 | size = sb->s_op->quota_read(sb, type, (char *)&dqhead, |
58 | sizeof(struct v2_disk_dqheader), 0); | ||
58 | if (size != sizeof(struct v2_disk_dqheader)) { | 59 | if (size != sizeof(struct v2_disk_dqheader)) { |
59 | printk("quota_v2: failed read expected=%zd got=%zd\n", | 60 | printk("quota_v2: failed read expected=%zd got=%zd\n", |
60 | sizeof(struct v2_disk_dqheader), size); | 61 | sizeof(struct v2_disk_dqheader), size); |
diff --git a/fs/quotaio_v1.h b/fs/quota/quotaio_v1.h index 746654b5de70..746654b5de70 100644 --- a/fs/quotaio_v1.h +++ b/fs/quota/quotaio_v1.h | |||
diff --git a/fs/quotaio_v2.h b/fs/quota/quotaio_v2.h index 530fe580685c..530fe580685c 100644 --- a/fs/quotaio_v2.h +++ b/fs/quota/quotaio_v2.h | |||
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index 5d7c7ececa64..995ef1d6686c 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/string.h> | 18 | #include <linux/string.h> |
19 | #include <linux/backing-dev.h> | 19 | #include <linux/backing-dev.h> |
20 | #include <linux/ramfs.h> | 20 | #include <linux/ramfs.h> |
21 | #include <linux/quotaops.h> | ||
22 | #include <linux/pagevec.h> | 21 | #include <linux/pagevec.h> |
23 | #include <linux/mman.h> | 22 | #include <linux/mman.h> |
24 | 23 | ||
@@ -205,11 +204,6 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia) | |||
205 | if (ret) | 204 | if (ret) |
206 | return ret; | 205 | return ret; |
207 | 206 | ||
208 | /* by providing our own setattr() method, we skip this quotaism */ | ||
209 | if ((old_ia_valid & ATTR_UID && ia->ia_uid != inode->i_uid) || | ||
210 | (old_ia_valid & ATTR_GID && ia->ia_gid != inode->i_gid)) | ||
211 | ret = DQUOT_TRANSFER(inode, ia) ? -EDQUOT : 0; | ||
212 | |||
213 | /* pick out size-changing events */ | 207 | /* pick out size-changing events */ |
214 | if (ia->ia_valid & ATTR_SIZE) { | 208 | if (ia->ia_valid & ATTR_SIZE) { |
215 | loff_t size = i_size_read(inode); | 209 | loff_t size = i_size_read(inode); |
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c index 4646caa60455..f32d1425cc9f 100644 --- a/fs/reiserfs/bitmap.c +++ b/fs/reiserfs/bitmap.c | |||
@@ -430,7 +430,7 @@ static void _reiserfs_free_block(struct reiserfs_transaction_handle *th, | |||
430 | 430 | ||
431 | journal_mark_dirty(th, s, sbh); | 431 | journal_mark_dirty(th, s, sbh); |
432 | if (for_unformatted) | 432 | if (for_unformatted) |
433 | DQUOT_FREE_BLOCK_NODIRTY(inode, 1); | 433 | vfs_dq_free_block_nodirty(inode, 1); |
434 | } | 434 | } |
435 | 435 | ||
436 | void reiserfs_free_block(struct reiserfs_transaction_handle *th, | 436 | void reiserfs_free_block(struct reiserfs_transaction_handle *th, |
@@ -1055,7 +1055,7 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start | |||
1055 | amount_needed, hint->inode->i_uid); | 1055 | amount_needed, hint->inode->i_uid); |
1056 | #endif | 1056 | #endif |
1057 | quota_ret = | 1057 | quota_ret = |
1058 | DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed); | 1058 | vfs_dq_alloc_block_nodirty(hint->inode, amount_needed); |
1059 | if (quota_ret) /* Quota exceeded? */ | 1059 | if (quota_ret) /* Quota exceeded? */ |
1060 | return QUOTA_EXCEEDED; | 1060 | return QUOTA_EXCEEDED; |
1061 | if (hint->preallocate && hint->prealloc_size) { | 1061 | if (hint->preallocate && hint->prealloc_size) { |
@@ -1064,8 +1064,7 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start | |||
1064 | "reiserquota: allocating (prealloc) %d blocks id=%u", | 1064 | "reiserquota: allocating (prealloc) %d blocks id=%u", |
1065 | hint->prealloc_size, hint->inode->i_uid); | 1065 | hint->prealloc_size, hint->inode->i_uid); |
1066 | #endif | 1066 | #endif |
1067 | quota_ret = | 1067 | quota_ret = vfs_dq_prealloc_block_nodirty(hint->inode, |
1068 | DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode, | ||
1069 | hint->prealloc_size); | 1068 | hint->prealloc_size); |
1070 | if (quota_ret) | 1069 | if (quota_ret) |
1071 | hint->preallocate = hint->prealloc_size = 0; | 1070 | hint->preallocate = hint->prealloc_size = 0; |
@@ -1098,7 +1097,10 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start | |||
1098 | nr_allocated, | 1097 | nr_allocated, |
1099 | hint->inode->i_uid); | 1098 | hint->inode->i_uid); |
1100 | #endif | 1099 | #endif |
1101 | DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */ | 1100 | /* Free not allocated blocks */ |
1101 | vfs_dq_free_block_nodirty(hint->inode, | ||
1102 | amount_needed + hint->prealloc_size - | ||
1103 | nr_allocated); | ||
1102 | } | 1104 | } |
1103 | while (nr_allocated--) | 1105 | while (nr_allocated--) |
1104 | reiserfs_free_block(hint->th, hint->inode, | 1106 | reiserfs_free_block(hint->th, hint->inode, |
@@ -1129,7 +1131,7 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start | |||
1129 | REISERFS_I(hint->inode)->i_prealloc_count, | 1131 | REISERFS_I(hint->inode)->i_prealloc_count, |
1130 | hint->inode->i_uid); | 1132 | hint->inode->i_uid); |
1131 | #endif | 1133 | #endif |
1132 | DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + | 1134 | vfs_dq_free_block_nodirty(hint->inode, amount_needed + |
1133 | hint->prealloc_size - nr_allocated - | 1135 | hint->prealloc_size - nr_allocated - |
1134 | REISERFS_I(hint->inode)-> | 1136 | REISERFS_I(hint->inode)-> |
1135 | i_prealloc_count); | 1137 | i_prealloc_count); |
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index 55fce92cdf18..823227a7662a 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -53,7 +53,7 @@ void reiserfs_delete_inode(struct inode *inode) | |||
53 | * after delete_object so that quota updates go into the same transaction as | 53 | * after delete_object so that quota updates go into the same transaction as |
54 | * stat data deletion */ | 54 | * stat data deletion */ |
55 | if (!err) | 55 | if (!err) |
56 | DQUOT_FREE_INODE(inode); | 56 | vfs_dq_free_inode(inode); |
57 | 57 | ||
58 | if (journal_end(&th, inode->i_sb, jbegin_count)) | 58 | if (journal_end(&th, inode->i_sb, jbegin_count)) |
59 | goto out; | 59 | goto out; |
@@ -1763,7 +1763,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, | |||
1763 | 1763 | ||
1764 | BUG_ON(!th->t_trans_id); | 1764 | BUG_ON(!th->t_trans_id); |
1765 | 1765 | ||
1766 | if (DQUOT_ALLOC_INODE(inode)) { | 1766 | if (vfs_dq_alloc_inode(inode)) { |
1767 | err = -EDQUOT; | 1767 | err = -EDQUOT; |
1768 | goto out_end_trans; | 1768 | goto out_end_trans; |
1769 | } | 1769 | } |
@@ -1947,12 +1947,12 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, | |||
1947 | INODE_PKEY(inode)->k_objectid = 0; | 1947 | INODE_PKEY(inode)->k_objectid = 0; |
1948 | 1948 | ||
1949 | /* Quota change must be inside a transaction for journaling */ | 1949 | /* Quota change must be inside a transaction for journaling */ |
1950 | DQUOT_FREE_INODE(inode); | 1950 | vfs_dq_free_inode(inode); |
1951 | 1951 | ||
1952 | out_end_trans: | 1952 | out_end_trans: |
1953 | journal_end(th, th->t_super, th->t_blocks_allocated); | 1953 | journal_end(th, th->t_super, th->t_blocks_allocated); |
1954 | /* Drop can be outside and it needs more credits so it's better to have it outside */ | 1954 | /* Drop can be outside and it needs more credits so it's better to have it outside */ |
1955 | DQUOT_DROP(inode); | 1955 | vfs_dq_drop(inode); |
1956 | inode->i_flags |= S_NOQUOTA; | 1956 | inode->i_flags |= S_NOQUOTA; |
1957 | make_bad_inode(inode); | 1957 | make_bad_inode(inode); |
1958 | 1958 | ||
@@ -3119,7 +3119,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
3119 | if (error) | 3119 | if (error) |
3120 | goto out; | 3120 | goto out; |
3121 | error = | 3121 | error = |
3122 | DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0; | 3122 | vfs_dq_transfer(inode, attr) ? -EDQUOT : 0; |
3123 | if (error) { | 3123 | if (error) { |
3124 | journal_end(&th, inode->i_sb, | 3124 | journal_end(&th, inode->i_sb, |
3125 | jbegin_count); | 3125 | jbegin_count); |
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index 738967f6c8ee..639d635d9d4b 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c | |||
@@ -555,7 +555,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th, | |||
555 | */ | 555 | */ |
556 | static int drop_new_inode(struct inode *inode) | 556 | static int drop_new_inode(struct inode *inode) |
557 | { | 557 | { |
558 | DQUOT_DROP(inode); | 558 | vfs_dq_drop(inode); |
559 | make_bad_inode(inode); | 559 | make_bad_inode(inode); |
560 | inode->i_flags |= S_NOQUOTA; | 560 | inode->i_flags |= S_NOQUOTA; |
561 | iput(inode); | 561 | iput(inode); |
@@ -563,7 +563,7 @@ static int drop_new_inode(struct inode *inode) | |||
563 | } | 563 | } |
564 | 564 | ||
565 | /* utility function that does setup for reiserfs_new_inode. | 565 | /* utility function that does setup for reiserfs_new_inode. |
566 | ** DQUOT_INIT needs lots of credits so it's better to have it | 566 | ** vfs_dq_init needs lots of credits so it's better to have it |
567 | ** outside of a transaction, so we had to pull some bits of | 567 | ** outside of a transaction, so we had to pull some bits of |
568 | ** reiserfs_new_inode out into this func. | 568 | ** reiserfs_new_inode out into this func. |
569 | */ | 569 | */ |
@@ -586,7 +586,7 @@ static int new_inode_init(struct inode *inode, struct inode *dir, int mode) | |||
586 | } else { | 586 | } else { |
587 | inode->i_gid = current_fsgid(); | 587 | inode->i_gid = current_fsgid(); |
588 | } | 588 | } |
589 | DQUOT_INIT(inode); | 589 | vfs_dq_init(inode); |
590 | return 0; | 590 | return 0; |
591 | } | 591 | } |
592 | 592 | ||
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c index abbc64dcc8d4..73aaa33f6735 100644 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c | |||
@@ -1297,7 +1297,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath | |||
1297 | "reiserquota delete_item(): freeing %u, id=%u type=%c", | 1297 | "reiserquota delete_item(): freeing %u, id=%u type=%c", |
1298 | quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih)); | 1298 | quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih)); |
1299 | #endif | 1299 | #endif |
1300 | DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes); | 1300 | vfs_dq_free_space_nodirty(p_s_inode, quota_cut_bytes); |
1301 | 1301 | ||
1302 | /* Return deleted body length */ | 1302 | /* Return deleted body length */ |
1303 | return n_ret_value; | 1303 | return n_ret_value; |
@@ -1383,7 +1383,7 @@ void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th, | |||
1383 | quota_cut_bytes, inode->i_uid, | 1383 | quota_cut_bytes, inode->i_uid, |
1384 | key2type(key)); | 1384 | key2type(key)); |
1385 | #endif | 1385 | #endif |
1386 | DQUOT_FREE_SPACE_NODIRTY(inode, | 1386 | vfs_dq_free_space_nodirty(inode, |
1387 | quota_cut_bytes); | 1387 | quota_cut_bytes); |
1388 | } | 1388 | } |
1389 | break; | 1389 | break; |
@@ -1734,7 +1734,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1734 | "reiserquota cut_from_item(): freeing %u id=%u type=%c", | 1734 | "reiserquota cut_from_item(): freeing %u id=%u type=%c", |
1735 | quota_cut_bytes, p_s_inode->i_uid, '?'); | 1735 | quota_cut_bytes, p_s_inode->i_uid, '?'); |
1736 | #endif | 1736 | #endif |
1737 | DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes); | 1737 | vfs_dq_free_space_nodirty(p_s_inode, quota_cut_bytes); |
1738 | return n_ret_value; | 1738 | return n_ret_value; |
1739 | } | 1739 | } |
1740 | 1740 | ||
@@ -1971,7 +1971,7 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree | |||
1971 | key2type(&(p_s_key->on_disk_key))); | 1971 | key2type(&(p_s_key->on_disk_key))); |
1972 | #endif | 1972 | #endif |
1973 | 1973 | ||
1974 | if (DQUOT_ALLOC_SPACE_NODIRTY(inode, n_pasted_size)) { | 1974 | if (vfs_dq_alloc_space_nodirty(inode, n_pasted_size)) { |
1975 | pathrelse(p_s_search_path); | 1975 | pathrelse(p_s_search_path); |
1976 | return -EDQUOT; | 1976 | return -EDQUOT; |
1977 | } | 1977 | } |
@@ -2027,7 +2027,7 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree | |||
2027 | n_pasted_size, inode->i_uid, | 2027 | n_pasted_size, inode->i_uid, |
2028 | key2type(&(p_s_key->on_disk_key))); | 2028 | key2type(&(p_s_key->on_disk_key))); |
2029 | #endif | 2029 | #endif |
2030 | DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size); | 2030 | vfs_dq_free_space_nodirty(inode, n_pasted_size); |
2031 | return retval; | 2031 | return retval; |
2032 | } | 2032 | } |
2033 | 2033 | ||
@@ -2060,7 +2060,7 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath | |||
2060 | #endif | 2060 | #endif |
2061 | /* We can't dirty inode here. It would be immediately written but | 2061 | /* We can't dirty inode here. It would be immediately written but |
2062 | * appropriate stat item isn't inserted yet... */ | 2062 | * appropriate stat item isn't inserted yet... */ |
2063 | if (DQUOT_ALLOC_SPACE_NODIRTY(inode, quota_bytes)) { | 2063 | if (vfs_dq_alloc_space_nodirty(inode, quota_bytes)) { |
2064 | pathrelse(p_s_path); | 2064 | pathrelse(p_s_path); |
2065 | return -EDQUOT; | 2065 | return -EDQUOT; |
2066 | } | 2066 | } |
@@ -2112,6 +2112,6 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath | |||
2112 | quota_bytes, inode->i_uid, head2type(p_s_ih)); | 2112 | quota_bytes, inode->i_uid, head2type(p_s_ih)); |
2113 | #endif | 2113 | #endif |
2114 | if (inode) | 2114 | if (inode) |
2115 | DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes); | 2115 | vfs_dq_free_space_nodirty(inode, quota_bytes); |
2116 | return retval; | 2116 | return retval; |
2117 | } | 2117 | } |
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index f3c820b75829..5dbafb739401 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
@@ -250,7 +250,7 @@ static int finish_unfinished(struct super_block *s) | |||
250 | retval = remove_save_link_only(s, &save_link_key, 0); | 250 | retval = remove_save_link_only(s, &save_link_key, 0); |
251 | continue; | 251 | continue; |
252 | } | 252 | } |
253 | DQUOT_INIT(inode); | 253 | vfs_dq_init(inode); |
254 | 254 | ||
255 | if (truncate && S_ISDIR(inode->i_mode)) { | 255 | if (truncate && S_ISDIR(inode->i_mode)) { |
256 | /* We got a truncate request for a dir which is impossible. | 256 | /* We got a truncate request for a dir which is impossible. |
@@ -629,8 +629,6 @@ static const struct super_operations reiserfs_sops = { | |||
629 | #ifdef CONFIG_QUOTA | 629 | #ifdef CONFIG_QUOTA |
630 | #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group") | 630 | #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group") |
631 | 631 | ||
632 | static int reiserfs_dquot_initialize(struct inode *, int); | ||
633 | static int reiserfs_dquot_drop(struct inode *); | ||
634 | static int reiserfs_write_dquot(struct dquot *); | 632 | static int reiserfs_write_dquot(struct dquot *); |
635 | static int reiserfs_acquire_dquot(struct dquot *); | 633 | static int reiserfs_acquire_dquot(struct dquot *); |
636 | static int reiserfs_release_dquot(struct dquot *); | 634 | static int reiserfs_release_dquot(struct dquot *); |
@@ -639,8 +637,8 @@ static int reiserfs_write_info(struct super_block *, int); | |||
639 | static int reiserfs_quota_on(struct super_block *, int, int, char *, int); | 637 | static int reiserfs_quota_on(struct super_block *, int, int, char *, int); |
640 | 638 | ||
641 | static struct dquot_operations reiserfs_quota_operations = { | 639 | static struct dquot_operations reiserfs_quota_operations = { |
642 | .initialize = reiserfs_dquot_initialize, | 640 | .initialize = dquot_initialize, |
643 | .drop = reiserfs_dquot_drop, | 641 | .drop = dquot_drop, |
644 | .alloc_space = dquot_alloc_space, | 642 | .alloc_space = dquot_alloc_space, |
645 | .alloc_inode = dquot_alloc_inode, | 643 | .alloc_inode = dquot_alloc_inode, |
646 | .free_space = dquot_free_space, | 644 | .free_space = dquot_free_space, |
@@ -1896,58 +1894,6 @@ static int reiserfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
1896 | } | 1894 | } |
1897 | 1895 | ||
1898 | #ifdef CONFIG_QUOTA | 1896 | #ifdef CONFIG_QUOTA |
1899 | static int reiserfs_dquot_initialize(struct inode *inode, int type) | ||
1900 | { | ||
1901 | struct reiserfs_transaction_handle th; | ||
1902 | int ret, err; | ||
1903 | |||
1904 | /* We may create quota structure so we need to reserve enough blocks */ | ||
1905 | reiserfs_write_lock(inode->i_sb); | ||
1906 | ret = | ||
1907 | journal_begin(&th, inode->i_sb, | ||
1908 | 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb)); | ||
1909 | if (ret) | ||
1910 | goto out; | ||
1911 | ret = dquot_initialize(inode, type); | ||
1912 | err = | ||
1913 | journal_end(&th, inode->i_sb, | ||
1914 | 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb)); | ||
1915 | if (!ret && err) | ||
1916 | ret = err; | ||
1917 | out: | ||
1918 | reiserfs_write_unlock(inode->i_sb); | ||
1919 | return ret; | ||
1920 | } | ||
1921 | |||
1922 | static int reiserfs_dquot_drop(struct inode *inode) | ||
1923 | { | ||
1924 | struct reiserfs_transaction_handle th; | ||
1925 | int ret, err; | ||
1926 | |||
1927 | /* We may delete quota structure so we need to reserve enough blocks */ | ||
1928 | reiserfs_write_lock(inode->i_sb); | ||
1929 | ret = | ||
1930 | journal_begin(&th, inode->i_sb, | ||
1931 | 2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb)); | ||
1932 | if (ret) { | ||
1933 | /* | ||
1934 | * We call dquot_drop() anyway to at least release references | ||
1935 | * to quota structures so that umount does not hang. | ||
1936 | */ | ||
1937 | dquot_drop(inode); | ||
1938 | goto out; | ||
1939 | } | ||
1940 | ret = dquot_drop(inode); | ||
1941 | err = | ||
1942 | journal_end(&th, inode->i_sb, | ||
1943 | 2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb)); | ||
1944 | if (!ret && err) | ||
1945 | ret = err; | ||
1946 | out: | ||
1947 | reiserfs_write_unlock(inode->i_sb); | ||
1948 | return ret; | ||
1949 | } | ||
1950 | |||
1951 | static int reiserfs_write_dquot(struct dquot *dquot) | 1897 | static int reiserfs_write_dquot(struct dquot *dquot) |
1952 | { | 1898 | { |
1953 | struct reiserfs_transaction_handle th; | 1899 | struct reiserfs_transaction_handle th; |
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index ad92461cbfc3..ae881ccd2f03 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
@@ -1136,7 +1136,7 @@ xattr_lookup_poison(struct dentry *dentry, struct qstr *q1, struct qstr *name) | |||
1136 | return 1; | 1136 | return 1; |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | static struct dentry_operations xattr_lookup_poison_ops = { | 1139 | static const struct dentry_operations xattr_lookup_poison_ops = { |
1140 | .d_compare = xattr_lookup_poison, | 1140 | .d_compare = xattr_lookup_poison, |
1141 | }; | 1141 | }; |
1142 | 1142 | ||
diff --git a/fs/smbfs/dir.c b/fs/smbfs/dir.c index e7ddd0328ddc..3e4803b4427e 100644 --- a/fs/smbfs/dir.c +++ b/fs/smbfs/dir.c | |||
@@ -277,7 +277,7 @@ static int smb_hash_dentry(struct dentry *, struct qstr *); | |||
277 | static int smb_compare_dentry(struct dentry *, struct qstr *, struct qstr *); | 277 | static int smb_compare_dentry(struct dentry *, struct qstr *, struct qstr *); |
278 | static int smb_delete_dentry(struct dentry *); | 278 | static int smb_delete_dentry(struct dentry *); |
279 | 279 | ||
280 | static struct dentry_operations smbfs_dentry_operations = | 280 | static const struct dentry_operations smbfs_dentry_operations = |
281 | { | 281 | { |
282 | .d_revalidate = smb_lookup_validate, | 282 | .d_revalidate = smb_lookup_validate, |
283 | .d_hash = smb_hash_dentry, | 283 | .d_hash = smb_hash_dentry, |
@@ -285,7 +285,7 @@ static struct dentry_operations smbfs_dentry_operations = | |||
285 | .d_delete = smb_delete_dentry, | 285 | .d_delete = smb_delete_dentry, |
286 | }; | 286 | }; |
287 | 287 | ||
288 | static struct dentry_operations smbfs_dentry_operations_case = | 288 | static const struct dentry_operations smbfs_dentry_operations_case = |
289 | { | 289 | { |
290 | .d_revalidate = smb_lookup_validate, | 290 | .d_revalidate = smb_lookup_validate, |
291 | .d_delete = smb_delete_dentry, | 291 | .d_delete = smb_delete_dentry, |
diff --git a/fs/super.c b/fs/super.c index dd4acb158b5e..2ba481518ba7 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -197,7 +197,7 @@ void deactivate_super(struct super_block *s) | |||
197 | if (atomic_dec_and_lock(&s->s_active, &sb_lock)) { | 197 | if (atomic_dec_and_lock(&s->s_active, &sb_lock)) { |
198 | s->s_count -= S_BIAS-1; | 198 | s->s_count -= S_BIAS-1; |
199 | spin_unlock(&sb_lock); | 199 | spin_unlock(&sb_lock); |
200 | DQUOT_OFF(s, 0); | 200 | vfs_dq_off(s, 0); |
201 | down_write(&s->s_umount); | 201 | down_write(&s->s_umount); |
202 | fs->kill_sb(s); | 202 | fs->kill_sb(s); |
203 | put_filesystem(fs); | 203 | put_filesystem(fs); |
@@ -266,7 +266,7 @@ EXPORT_SYMBOL(unlock_super); | |||
266 | void __fsync_super(struct super_block *sb) | 266 | void __fsync_super(struct super_block *sb) |
267 | { | 267 | { |
268 | sync_inodes_sb(sb, 0); | 268 | sync_inodes_sb(sb, 0); |
269 | DQUOT_SYNC(sb); | 269 | vfs_dq_sync(sb); |
270 | lock_super(sb); | 270 | lock_super(sb); |
271 | if (sb->s_dirt && sb->s_op->write_super) | 271 | if (sb->s_dirt && sb->s_op->write_super) |
272 | sb->s_op->write_super(sb); | 272 | sb->s_op->write_super(sb); |
@@ -655,7 +655,7 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) | |||
655 | mark_files_ro(sb); | 655 | mark_files_ro(sb); |
656 | else if (!fs_may_remount_ro(sb)) | 656 | else if (!fs_may_remount_ro(sb)) |
657 | return -EBUSY; | 657 | return -EBUSY; |
658 | retval = DQUOT_OFF(sb, 1); | 658 | retval = vfs_dq_off(sb, 1); |
659 | if (retval < 0 && retval != -ENOSYS) | 659 | if (retval < 0 && retval != -ENOSYS) |
660 | return -EBUSY; | 660 | return -EBUSY; |
661 | } | 661 | } |
@@ -670,7 +670,7 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) | |||
670 | } | 670 | } |
671 | sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK); | 671 | sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK); |
672 | if (remount_rw) | 672 | if (remount_rw) |
673 | DQUOT_ON_REMOUNT(sb); | 673 | vfs_dq_quota_on_remount(sb); |
674 | return 0; | 674 | return 0; |
675 | } | 675 | } |
676 | 676 | ||
@@ -838,7 +838,8 @@ int get_sb_bdev(struct file_system_type *fs_type, | |||
838 | bdev->bd_super = s; | 838 | bdev->bd_super = s; |
839 | } | 839 | } |
840 | 840 | ||
841 | return simple_set_mnt(mnt, s); | 841 | simple_set_mnt(mnt, s); |
842 | return 0; | ||
842 | 843 | ||
843 | error_s: | 844 | error_s: |
844 | error = PTR_ERR(s); | 845 | error = PTR_ERR(s); |
@@ -884,7 +885,8 @@ int get_sb_nodev(struct file_system_type *fs_type, | |||
884 | return error; | 885 | return error; |
885 | } | 886 | } |
886 | s->s_flags |= MS_ACTIVE; | 887 | s->s_flags |= MS_ACTIVE; |
887 | return simple_set_mnt(mnt, s); | 888 | simple_set_mnt(mnt, s); |
889 | return 0; | ||
888 | } | 890 | } |
889 | 891 | ||
890 | EXPORT_SYMBOL(get_sb_nodev); | 892 | EXPORT_SYMBOL(get_sb_nodev); |
@@ -916,7 +918,8 @@ int get_sb_single(struct file_system_type *fs_type, | |||
916 | s->s_flags |= MS_ACTIVE; | 918 | s->s_flags |= MS_ACTIVE; |
917 | } | 919 | } |
918 | do_remount_sb(s, flags, data, 0); | 920 | do_remount_sb(s, flags, data, 0); |
919 | return simple_set_mnt(mnt, s); | 921 | simple_set_mnt(mnt, s); |
922 | return 0; | ||
920 | } | 923 | } |
921 | 924 | ||
922 | EXPORT_SYMBOL(get_sb_single); | 925 | EXPORT_SYMBOL(get_sb_single); |
@@ -25,7 +25,7 @@ static void do_sync(unsigned long wait) | |||
25 | { | 25 | { |
26 | wakeup_pdflush(0); | 26 | wakeup_pdflush(0); |
27 | sync_inodes(0); /* All mappings, inodes and their blockdevs */ | 27 | sync_inodes(0); /* All mappings, inodes and their blockdevs */ |
28 | DQUOT_SYNC(NULL); | 28 | vfs_dq_sync(NULL); |
29 | sync_supers(); /* Write the superblocks */ | 29 | sync_supers(); /* Write the superblocks */ |
30 | sync_filesystems(0); /* Start syncing the filesystems */ | 30 | sync_filesystems(0); /* Start syncing the filesystems */ |
31 | sync_filesystems(wait); /* Waitingly sync the filesystems */ | 31 | sync_filesystems(wait); /* Waitingly sync the filesystems */ |
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 66aeb4fff0c3..d88d0fac9fa5 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -302,7 +302,7 @@ static void sysfs_d_iput(struct dentry * dentry, struct inode * inode) | |||
302 | iput(inode); | 302 | iput(inode); |
303 | } | 303 | } |
304 | 304 | ||
305 | static struct dentry_operations sysfs_dentry_ops = { | 305 | static const struct dentry_operations sysfs_dentry_ops = { |
306 | .d_iput = sysfs_d_iput, | 306 | .d_iput = sysfs_d_iput, |
307 | }; | 307 | }; |
308 | 308 | ||
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index a1f1ef33e81c..33e047b59b8d 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c | |||
@@ -38,7 +38,7 @@ static int sysv_hash(struct dentry *dentry, struct qstr *qstr) | |||
38 | return 0; | 38 | return 0; |
39 | } | 39 | } |
40 | 40 | ||
41 | struct dentry_operations sysv_dentry_operations = { | 41 | const struct dentry_operations sysv_dentry_operations = { |
42 | .d_hash = sysv_hash, | 42 | .d_hash = sysv_hash, |
43 | }; | 43 | }; |
44 | 44 | ||
diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h index 38ebe3f85b3d..5784a318c883 100644 --- a/fs/sysv/sysv.h +++ b/fs/sysv/sysv.h | |||
@@ -170,7 +170,7 @@ extern const struct file_operations sysv_file_operations; | |||
170 | extern const struct file_operations sysv_dir_operations; | 170 | extern const struct file_operations sysv_dir_operations; |
171 | extern const struct address_space_operations sysv_aops; | 171 | extern const struct address_space_operations sysv_aops; |
172 | extern const struct super_operations sysv_sops; | 172 | extern const struct super_operations sysv_sops; |
173 | extern struct dentry_operations sysv_dentry_operations; | 173 | extern const struct dentry_operations sysv_dentry_operations; |
174 | 174 | ||
175 | 175 | ||
176 | enum { | 176 | enum { |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 1182b66a5491..c5c98355459a 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -2034,7 +2034,8 @@ static int ubifs_get_sb(struct file_system_type *fs_type, int flags, | |||
2034 | /* 'fill_super()' opens ubi again so we must close it here */ | 2034 | /* 'fill_super()' opens ubi again so we must close it here */ |
2035 | ubi_close_volume(ubi); | 2035 | ubi_close_volume(ubi); |
2036 | 2036 | ||
2037 | return simple_set_mnt(mnt, sb); | 2037 | simple_set_mnt(mnt, sb); |
2038 | return 0; | ||
2038 | 2039 | ||
2039 | out_deact: | 2040 | out_deact: |
2040 | up_write(&sb->s_umount); | 2041 | up_write(&sb->s_umount); |
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index 1b809bd494bd..2bb788a2acb1 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c | |||
@@ -206,7 +206,7 @@ static void udf_bitmap_free_blocks(struct super_block *sb, | |||
206 | ((char *)bh->b_data)[(bit + i) >> 3]); | 206 | ((char *)bh->b_data)[(bit + i) >> 3]); |
207 | } else { | 207 | } else { |
208 | if (inode) | 208 | if (inode) |
209 | DQUOT_FREE_BLOCK(inode, 1); | 209 | vfs_dq_free_block(inode, 1); |
210 | udf_add_free_space(sbi, sbi->s_partition, 1); | 210 | udf_add_free_space(sbi, sbi->s_partition, 1); |
211 | } | 211 | } |
212 | } | 212 | } |
@@ -261,11 +261,11 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb, | |||
261 | while (bit < (sb->s_blocksize << 3) && block_count > 0) { | 261 | while (bit < (sb->s_blocksize << 3) && block_count > 0) { |
262 | if (!udf_test_bit(bit, bh->b_data)) | 262 | if (!udf_test_bit(bit, bh->b_data)) |
263 | goto out; | 263 | goto out; |
264 | else if (DQUOT_PREALLOC_BLOCK(inode, 1)) | 264 | else if (vfs_dq_prealloc_block(inode, 1)) |
265 | goto out; | 265 | goto out; |
266 | else if (!udf_clear_bit(bit, bh->b_data)) { | 266 | else if (!udf_clear_bit(bit, bh->b_data)) { |
267 | udf_debug("bit already cleared for block %d\n", bit); | 267 | udf_debug("bit already cleared for block %d\n", bit); |
268 | DQUOT_FREE_BLOCK(inode, 1); | 268 | vfs_dq_free_block(inode, 1); |
269 | goto out; | 269 | goto out; |
270 | } | 270 | } |
271 | block_count--; | 271 | block_count--; |
@@ -393,7 +393,7 @@ got_block: | |||
393 | /* | 393 | /* |
394 | * Check quota for allocation of this block. | 394 | * Check quota for allocation of this block. |
395 | */ | 395 | */ |
396 | if (inode && DQUOT_ALLOC_BLOCK(inode, 1)) { | 396 | if (inode && vfs_dq_alloc_block(inode, 1)) { |
397 | mutex_unlock(&sbi->s_alloc_mutex); | 397 | mutex_unlock(&sbi->s_alloc_mutex); |
398 | *err = -EDQUOT; | 398 | *err = -EDQUOT; |
399 | return 0; | 399 | return 0; |
@@ -452,7 +452,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
452 | /* We do this up front - There are some error conditions that | 452 | /* We do this up front - There are some error conditions that |
453 | could occure, but.. oh well */ | 453 | could occure, but.. oh well */ |
454 | if (inode) | 454 | if (inode) |
455 | DQUOT_FREE_BLOCK(inode, count); | 455 | vfs_dq_free_block(inode, count); |
456 | if (udf_add_free_space(sbi, sbi->s_partition, count)) | 456 | if (udf_add_free_space(sbi, sbi->s_partition, count)) |
457 | mark_buffer_dirty(sbi->s_lvid_bh); | 457 | mark_buffer_dirty(sbi->s_lvid_bh); |
458 | 458 | ||
@@ -700,7 +700,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb, | |||
700 | epos.offset -= adsize; | 700 | epos.offset -= adsize; |
701 | 701 | ||
702 | alloc_count = (elen >> sb->s_blocksize_bits); | 702 | alloc_count = (elen >> sb->s_blocksize_bits); |
703 | if (inode && DQUOT_PREALLOC_BLOCK(inode, | 703 | if (inode && vfs_dq_prealloc_block(inode, |
704 | alloc_count > block_count ? block_count : alloc_count)) | 704 | alloc_count > block_count ? block_count : alloc_count)) |
705 | alloc_count = 0; | 705 | alloc_count = 0; |
706 | else if (alloc_count > block_count) { | 706 | else if (alloc_count > block_count) { |
@@ -806,7 +806,7 @@ static int udf_table_new_block(struct super_block *sb, | |||
806 | goal_eloc.logicalBlockNum++; | 806 | goal_eloc.logicalBlockNum++; |
807 | goal_elen -= sb->s_blocksize; | 807 | goal_elen -= sb->s_blocksize; |
808 | 808 | ||
809 | if (inode && DQUOT_ALLOC_BLOCK(inode, 1)) { | 809 | if (inode && vfs_dq_alloc_block(inode, 1)) { |
810 | brelse(goal_epos.bh); | 810 | brelse(goal_epos.bh); |
811 | mutex_unlock(&sbi->s_alloc_mutex); | 811 | mutex_unlock(&sbi->s_alloc_mutex); |
812 | *err = -EDQUOT; | 812 | *err = -EDQUOT; |
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c index 31fc84297ddb..47dbe5613f90 100644 --- a/fs/udf/ialloc.c +++ b/fs/udf/ialloc.c | |||
@@ -36,8 +36,8 @@ void udf_free_inode(struct inode *inode) | |||
36 | * Note: we must free any quota before locking the superblock, | 36 | * Note: we must free any quota before locking the superblock, |
37 | * as writing the quota to disk may need the lock as well. | 37 | * as writing the quota to disk may need the lock as well. |
38 | */ | 38 | */ |
39 | DQUOT_FREE_INODE(inode); | 39 | vfs_dq_free_inode(inode); |
40 | DQUOT_DROP(inode); | 40 | vfs_dq_drop(inode); |
41 | 41 | ||
42 | clear_inode(inode); | 42 | clear_inode(inode); |
43 | 43 | ||
@@ -154,8 +154,8 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
154 | insert_inode_hash(inode); | 154 | insert_inode_hash(inode); |
155 | mark_inode_dirty(inode); | 155 | mark_inode_dirty(inode); |
156 | 156 | ||
157 | if (DQUOT_ALLOC_INODE(inode)) { | 157 | if (vfs_dq_alloc_inode(inode)) { |
158 | DQUOT_DROP(inode); | 158 | vfs_dq_drop(inode); |
159 | inode->i_flags |= S_NOQUOTA; | 159 | inode->i_flags |= S_NOQUOTA; |
160 | inode->i_nlink = 0; | 160 | inode->i_nlink = 0; |
161 | iput(inode); | 161 | iput(inode); |
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index 0d9ada173739..54c16ec95dff 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c | |||
@@ -85,7 +85,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) | |||
85 | "bit already cleared for fragment %u", i); | 85 | "bit already cleared for fragment %u", i); |
86 | } | 86 | } |
87 | 87 | ||
88 | DQUOT_FREE_BLOCK (inode, count); | 88 | vfs_dq_free_block(inode, count); |
89 | 89 | ||
90 | 90 | ||
91 | fs32_add(sb, &ucg->cg_cs.cs_nffree, count); | 91 | fs32_add(sb, &ucg->cg_cs.cs_nffree, count); |
@@ -195,7 +195,7 @@ do_more: | |||
195 | ubh_setblock(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); | 195 | ubh_setblock(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); |
196 | if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) | 196 | if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) |
197 | ufs_clusteracct (sb, ucpi, blkno, 1); | 197 | ufs_clusteracct (sb, ucpi, blkno, 1); |
198 | DQUOT_FREE_BLOCK(inode, uspi->s_fpb); | 198 | vfs_dq_free_block(inode, uspi->s_fpb); |
199 | 199 | ||
200 | fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1); | 200 | fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1); |
201 | uspi->cs_total.cs_nbfree++; | 201 | uspi->cs_total.cs_nbfree++; |
@@ -556,7 +556,7 @@ static u64 ufs_add_fragments(struct inode *inode, u64 fragment, | |||
556 | fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1); | 556 | fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1); |
557 | for (i = oldcount; i < newcount; i++) | 557 | for (i = oldcount; i < newcount; i++) |
558 | ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i); | 558 | ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i); |
559 | if(DQUOT_ALLOC_BLOCK(inode, count)) { | 559 | if (vfs_dq_alloc_block(inode, count)) { |
560 | *err = -EDQUOT; | 560 | *err = -EDQUOT; |
561 | return 0; | 561 | return 0; |
562 | } | 562 | } |
@@ -664,7 +664,7 @@ cg_found: | |||
664 | for (i = count; i < uspi->s_fpb; i++) | 664 | for (i = count; i < uspi->s_fpb; i++) |
665 | ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, goal + i); | 665 | ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, goal + i); |
666 | i = uspi->s_fpb - count; | 666 | i = uspi->s_fpb - count; |
667 | DQUOT_FREE_BLOCK(inode, i); | 667 | vfs_dq_free_block(inode, i); |
668 | 668 | ||
669 | fs32_add(sb, &ucg->cg_cs.cs_nffree, i); | 669 | fs32_add(sb, &ucg->cg_cs.cs_nffree, i); |
670 | uspi->cs_total.cs_nffree += i; | 670 | uspi->cs_total.cs_nffree += i; |
@@ -676,7 +676,7 @@ cg_found: | |||
676 | result = ufs_bitmap_search (sb, ucpi, goal, allocsize); | 676 | result = ufs_bitmap_search (sb, ucpi, goal, allocsize); |
677 | if (result == INVBLOCK) | 677 | if (result == INVBLOCK) |
678 | return 0; | 678 | return 0; |
679 | if(DQUOT_ALLOC_BLOCK(inode, count)) { | 679 | if (vfs_dq_alloc_block(inode, count)) { |
680 | *err = -EDQUOT; | 680 | *err = -EDQUOT; |
681 | return 0; | 681 | return 0; |
682 | } | 682 | } |
@@ -747,7 +747,7 @@ gotit: | |||
747 | ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); | 747 | ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); |
748 | if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) | 748 | if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) |
749 | ufs_clusteracct (sb, ucpi, blkno, -1); | 749 | ufs_clusteracct (sb, ucpi, blkno, -1); |
750 | if(DQUOT_ALLOC_BLOCK(inode, uspi->s_fpb)) { | 750 | if (vfs_dq_alloc_block(inode, uspi->s_fpb)) { |
751 | *err = -EDQUOT; | 751 | *err = -EDQUOT; |
752 | return INVBLOCK; | 752 | return INVBLOCK; |
753 | } | 753 | } |
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c index 6f5dcf006096..3527c00fef0d 100644 --- a/fs/ufs/ialloc.c +++ b/fs/ufs/ialloc.c | |||
@@ -95,8 +95,8 @@ void ufs_free_inode (struct inode * inode) | |||
95 | 95 | ||
96 | is_directory = S_ISDIR(inode->i_mode); | 96 | is_directory = S_ISDIR(inode->i_mode); |
97 | 97 | ||
98 | DQUOT_FREE_INODE(inode); | 98 | vfs_dq_free_inode(inode); |
99 | DQUOT_DROP(inode); | 99 | vfs_dq_drop(inode); |
100 | 100 | ||
101 | clear_inode (inode); | 101 | clear_inode (inode); |
102 | 102 | ||
@@ -355,8 +355,8 @@ cg_found: | |||
355 | 355 | ||
356 | unlock_super (sb); | 356 | unlock_super (sb); |
357 | 357 | ||
358 | if (DQUOT_ALLOC_INODE(inode)) { | 358 | if (vfs_dq_alloc_inode(inode)) { |
359 | DQUOT_DROP(inode); | 359 | vfs_dq_drop(inode); |
360 | err = -EDQUOT; | 360 | err = -EDQUOT; |
361 | goto fail_without_unlock; | 361 | goto fail_without_unlock; |
362 | } | 362 | } |
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 39f877898565..3d2512c21f05 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c | |||
@@ -622,7 +622,6 @@ static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode) | |||
622 | struct ufs_inode_info *ufsi = UFS_I(inode); | 622 | struct ufs_inode_info *ufsi = UFS_I(inode); |
623 | struct super_block *sb = inode->i_sb; | 623 | struct super_block *sb = inode->i_sb; |
624 | mode_t mode; | 624 | mode_t mode; |
625 | unsigned i; | ||
626 | 625 | ||
627 | /* | 626 | /* |
628 | * Copy data to the in-core inode. | 627 | * Copy data to the in-core inode. |
@@ -655,11 +654,12 @@ static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode) | |||
655 | 654 | ||
656 | 655 | ||
657 | if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { | 656 | if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { |
658 | for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) | 657 | memcpy(ufsi->i_u1.i_data, &ufs_inode->ui_u2.ui_addr, |
659 | ufsi->i_u1.i_data[i] = ufs_inode->ui_u2.ui_addr.ui_db[i]; | 658 | sizeof(ufs_inode->ui_u2.ui_addr)); |
660 | } else { | 659 | } else { |
661 | for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) | 660 | memcpy(ufsi->i_u1.i_symlink, ufs_inode->ui_u2.ui_symlink, |
662 | ufsi->i_u1.i_symlink[i] = ufs_inode->ui_u2.ui_symlink[i]; | 661 | sizeof(ufs_inode->ui_u2.ui_symlink) - 1); |
662 | ufsi->i_u1.i_symlink[sizeof(ufs_inode->ui_u2.ui_symlink) - 1] = 0; | ||
663 | } | 663 | } |
664 | return 0; | 664 | return 0; |
665 | } | 665 | } |
@@ -669,7 +669,6 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode) | |||
669 | struct ufs_inode_info *ufsi = UFS_I(inode); | 669 | struct ufs_inode_info *ufsi = UFS_I(inode); |
670 | struct super_block *sb = inode->i_sb; | 670 | struct super_block *sb = inode->i_sb; |
671 | mode_t mode; | 671 | mode_t mode; |
672 | unsigned i; | ||
673 | 672 | ||
674 | UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino); | 673 | UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino); |
675 | /* | 674 | /* |
@@ -704,12 +703,12 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode) | |||
704 | */ | 703 | */ |
705 | 704 | ||
706 | if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { | 705 | if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { |
707 | for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) | 706 | memcpy(ufsi->i_u1.u2_i_data, &ufs2_inode->ui_u2.ui_addr, |
708 | ufsi->i_u1.u2_i_data[i] = | 707 | sizeof(ufs2_inode->ui_u2.ui_addr)); |
709 | ufs2_inode->ui_u2.ui_addr.ui_db[i]; | ||
710 | } else { | 708 | } else { |
711 | for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) | 709 | memcpy(ufsi->i_u1.i_symlink, ufs2_inode->ui_u2.ui_symlink, |
712 | ufsi->i_u1.i_symlink[i] = ufs2_inode->ui_u2.ui_symlink[i]; | 710 | sizeof(ufs2_inode->ui_u2.ui_symlink) - 1); |
711 | ufsi->i_u1.i_symlink[sizeof(ufs2_inode->ui_u2.ui_symlink) - 1] = 0; | ||
713 | } | 712 | } |
714 | return 0; | 713 | return 0; |
715 | } | 714 | } |
@@ -781,7 +780,6 @@ static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode) | |||
781 | { | 780 | { |
782 | struct super_block *sb = inode->i_sb; | 781 | struct super_block *sb = inode->i_sb; |
783 | struct ufs_inode_info *ufsi = UFS_I(inode); | 782 | struct ufs_inode_info *ufsi = UFS_I(inode); |
784 | unsigned i; | ||
785 | 783 | ||
786 | ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode); | 784 | ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode); |
787 | ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink); | 785 | ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink); |
@@ -809,12 +807,12 @@ static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode) | |||
809 | /* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */ | 807 | /* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */ |
810 | ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.i_data[0]; | 808 | ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.i_data[0]; |
811 | } else if (inode->i_blocks) { | 809 | } else if (inode->i_blocks) { |
812 | for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) | 810 | memcpy(&ufs_inode->ui_u2.ui_addr, ufsi->i_u1.i_data, |
813 | ufs_inode->ui_u2.ui_addr.ui_db[i] = ufsi->i_u1.i_data[i]; | 811 | sizeof(ufs_inode->ui_u2.ui_addr)); |
814 | } | 812 | } |
815 | else { | 813 | else { |
816 | for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) | 814 | memcpy(&ufs_inode->ui_u2.ui_symlink, ufsi->i_u1.i_symlink, |
817 | ufs_inode->ui_u2.ui_symlink[i] = ufsi->i_u1.i_symlink[i]; | 815 | sizeof(ufs_inode->ui_u2.ui_symlink)); |
818 | } | 816 | } |
819 | 817 | ||
820 | if (!inode->i_nlink) | 818 | if (!inode->i_nlink) |
@@ -825,7 +823,6 @@ static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode) | |||
825 | { | 823 | { |
826 | struct super_block *sb = inode->i_sb; | 824 | struct super_block *sb = inode->i_sb; |
827 | struct ufs_inode_info *ufsi = UFS_I(inode); | 825 | struct ufs_inode_info *ufsi = UFS_I(inode); |
828 | unsigned i; | ||
829 | 826 | ||
830 | UFSD("ENTER\n"); | 827 | UFSD("ENTER\n"); |
831 | ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode); | 828 | ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode); |
@@ -850,11 +847,11 @@ static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode) | |||
850 | /* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */ | 847 | /* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */ |
851 | ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.u2_i_data[0]; | 848 | ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.u2_i_data[0]; |
852 | } else if (inode->i_blocks) { | 849 | } else if (inode->i_blocks) { |
853 | for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) | 850 | memcpy(&ufs_inode->ui_u2.ui_addr, ufsi->i_u1.u2_i_data, |
854 | ufs_inode->ui_u2.ui_addr.ui_db[i] = ufsi->i_u1.u2_i_data[i]; | 851 | sizeof(ufs_inode->ui_u2.ui_addr)); |
855 | } else { | 852 | } else { |
856 | for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) | 853 | memcpy(&ufs_inode->ui_u2.ui_symlink, ufsi->i_u1.i_symlink, |
857 | ufs_inode->ui_u2.ui_symlink[i] = ufsi->i_u1.i_symlink[i]; | 854 | sizeof(ufs_inode->ui_u2.ui_symlink)); |
858 | } | 855 | } |
859 | 856 | ||
860 | if (!inode->i_nlink) | 857 | if (!inode->i_nlink) |
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index e3a9b1fac75a..23119fe7ad62 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c | |||
@@ -147,7 +147,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry, | |||
147 | } else { | 147 | } else { |
148 | /* fast symlink */ | 148 | /* fast symlink */ |
149 | inode->i_op = &ufs_fast_symlink_inode_operations; | 149 | inode->i_op = &ufs_fast_symlink_inode_operations; |
150 | memcpy((char*)&UFS_I(inode)->i_u1.i_data,symname,l); | 150 | memcpy(UFS_I(inode)->i_u1.i_symlink, symname, l); |
151 | inode->i_size = l-1; | 151 | inode->i_size = l-1; |
152 | } | 152 | } |
153 | mark_inode_dirty(inode); | 153 | mark_inode_dirty(inode); |
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 261a1c2f22dd..e1c1fc5ee239 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -636,6 +636,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
636 | unsigned block_size, super_block_size; | 636 | unsigned block_size, super_block_size; |
637 | unsigned flags; | 637 | unsigned flags; |
638 | unsigned super_block_offset; | 638 | unsigned super_block_offset; |
639 | unsigned maxsymlen; | ||
639 | int ret = -EINVAL; | 640 | int ret = -EINVAL; |
640 | 641 | ||
641 | uspi = NULL; | 642 | uspi = NULL; |
@@ -1069,6 +1070,16 @@ magic_found: | |||
1069 | uspi->s_maxsymlinklen = | 1070 | uspi->s_maxsymlinklen = |
1070 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); | 1071 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); |
1071 | 1072 | ||
1073 | if (uspi->fs_magic == UFS2_MAGIC) | ||
1074 | maxsymlen = 2 * 4 * (UFS_NDADDR + UFS_NINDIR); | ||
1075 | else | ||
1076 | maxsymlen = 4 * (UFS_NDADDR + UFS_NINDIR); | ||
1077 | if (uspi->s_maxsymlinklen > maxsymlen) { | ||
1078 | ufs_warning(sb, __func__, "ufs_read_super: excessive maximum " | ||
1079 | "fast symlink size (%u)\n", uspi->s_maxsymlinklen); | ||
1080 | uspi->s_maxsymlinklen = maxsymlen; | ||
1081 | } | ||
1082 | |||
1072 | inode = ufs_iget(sb, UFS_ROOTINO); | 1083 | inode = ufs_iget(sb, UFS_ROOTINO); |
1073 | if (IS_ERR(inode)) { | 1084 | if (IS_ERR(inode)) { |
1074 | ret = PTR_ERR(inode); | 1085 | ret = PTR_ERR(inode); |
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index 11c035168ea6..69b3427d7885 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h | |||
@@ -23,7 +23,7 @@ struct ufs_sb_info { | |||
23 | struct ufs_inode_info { | 23 | struct ufs_inode_info { |
24 | union { | 24 | union { |
25 | __fs32 i_data[15]; | 25 | __fs32 i_data[15]; |
26 | __u8 i_symlink[4*15]; | 26 | __u8 i_symlink[2 * 4 * 15]; |
27 | __fs64 u2_i_data[15]; | 27 | __fs64 u2_i_data[15]; |
28 | } i_u1; | 28 | } i_u1; |
29 | __u32 i_flags; | 29 | __u32 i_flags; |