aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/namei.c')
-rw-r--r--fs/ocfs2/namei.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 0134bafdab9..6173807ba23 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -40,6 +40,7 @@
40#include <linux/types.h> 40#include <linux/types.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/highmem.h> 42#include <linux/highmem.h>
43#include <linux/quotaops.h>
43 44
44#define MLOG_MASK_PREFIX ML_NAMEI 45#define MLOG_MASK_PREFIX ML_NAMEI
45#include <cluster/masklog.h> 46#include <cluster/masklog.h>
@@ -212,6 +213,7 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode)
212 } else 213 } else
213 inode->i_gid = current_fsgid(); 214 inode->i_gid = current_fsgid();
214 inode->i_mode = mode; 215 inode->i_mode = mode;
216 vfs_dq_init(inode);
215 return inode; 217 return inode;
216} 218}
217 219
@@ -236,6 +238,7 @@ static int ocfs2_mknod(struct inode *dir,
236 struct ocfs2_security_xattr_info si = { 238 struct ocfs2_security_xattr_info si = {
237 .enable = 1, 239 .enable = 1,
238 }; 240 };
241 int did_quota_inode = 0;
239 242
240 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, 243 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
241 (unsigned long)dev, dentry->d_name.len, 244 (unsigned long)dev, dentry->d_name.len,
@@ -323,7 +326,8 @@ static int ocfs2_mknod(struct inode *dir,
323 goto leave; 326 goto leave;
324 } 327 }
325 328
326 handle = ocfs2_start_trans(osb, OCFS2_MKNOD_CREDITS + xattr_credits); 329 handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb) +
330 xattr_credits);
327 if (IS_ERR(handle)) { 331 if (IS_ERR(handle)) {
328 status = PTR_ERR(handle); 332 status = PTR_ERR(handle);
329 handle = NULL; 333 handle = NULL;
@@ -331,6 +335,15 @@ static int ocfs2_mknod(struct inode *dir,
331 goto leave; 335 goto leave;
332 } 336 }
333 337
338 /* We don't use standard VFS wrapper because we don't want vfs_dq_init
339 * to be called. */
340 if (sb_any_quota_active(osb->sb) &&
341 osb->sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
342 status = -EDQUOT;
343 goto leave;
344 }
345 did_quota_inode = 1;
346
334 /* do the real work now. */ 347 /* do the real work now. */
335 status = ocfs2_mknod_locked(osb, dir, inode, dentry, dev, 348 status = ocfs2_mknod_locked(osb, dir, inode, dentry, dev,
336 &new_fe_bh, parent_fe_bh, handle, 349 &new_fe_bh, parent_fe_bh, handle,
@@ -399,6 +412,8 @@ static int ocfs2_mknod(struct inode *dir,
399 d_instantiate(dentry, inode); 412 d_instantiate(dentry, inode);
400 status = 0; 413 status = 0;
401leave: 414leave:
415 if (status < 0 && did_quota_inode)
416 vfs_dq_free_inode(inode);
402 if (handle) 417 if (handle)
403 ocfs2_commit_trans(osb, handle); 418 ocfs2_commit_trans(osb, handle);
404 419
@@ -641,7 +656,7 @@ static int ocfs2_link(struct dentry *old_dentry,
641 goto out_unlock_inode; 656 goto out_unlock_inode;
642 } 657 }
643 658
644 handle = ocfs2_start_trans(osb, OCFS2_LINK_CREDITS); 659 handle = ocfs2_start_trans(osb, ocfs2_link_credits(osb->sb));
645 if (IS_ERR(handle)) { 660 if (IS_ERR(handle)) {
646 err = PTR_ERR(handle); 661 err = PTR_ERR(handle);
647 handle = NULL; 662 handle = NULL;
@@ -828,7 +843,7 @@ static int ocfs2_unlink(struct inode *dir,
828 } 843 }
829 } 844 }
830 845
831 handle = ocfs2_start_trans(osb, OCFS2_UNLINK_CREDITS); 846 handle = ocfs2_start_trans(osb, ocfs2_unlink_credits(osb->sb));
832 if (IS_ERR(handle)) { 847 if (IS_ERR(handle)) {
833 status = PTR_ERR(handle); 848 status = PTR_ERR(handle);
834 handle = NULL; 849 handle = NULL;
@@ -1234,7 +1249,7 @@ static int ocfs2_rename(struct inode *old_dir,
1234 } 1249 }
1235 } 1250 }
1236 1251
1237 handle = ocfs2_start_trans(osb, OCFS2_RENAME_CREDITS); 1252 handle = ocfs2_start_trans(osb, ocfs2_rename_credits(osb->sb));
1238 if (IS_ERR(handle)) { 1253 if (IS_ERR(handle)) {
1239 status = PTR_ERR(handle); 1254 status = PTR_ERR(handle);
1240 handle = NULL; 1255 handle = NULL;
@@ -1555,6 +1570,7 @@ static int ocfs2_symlink(struct inode *dir,
1555 struct ocfs2_security_xattr_info si = { 1570 struct ocfs2_security_xattr_info si = {
1556 .enable = 1, 1571 .enable = 1,
1557 }; 1572 };
1573 int did_quota = 0, did_quota_inode = 0;
1558 1574
1559 mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir, 1575 mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir,
1560 dentry, symname, dentry->d_name.len, dentry->d_name.name); 1576 dentry, symname, dentry->d_name.len, dentry->d_name.name);
@@ -1648,6 +1664,15 @@ static int ocfs2_symlink(struct inode *dir,
1648 goto bail; 1664 goto bail;
1649 } 1665 }
1650 1666
1667 /* We don't use standard VFS wrapper because we don't want vfs_dq_init
1668 * to be called. */
1669 if (sb_any_quota_active(osb->sb) &&
1670 osb->sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
1671 status = -EDQUOT;
1672 goto bail;
1673 }
1674 did_quota_inode = 1;
1675
1651 status = ocfs2_mknod_locked(osb, dir, inode, dentry, 1676 status = ocfs2_mknod_locked(osb, dir, inode, dentry,
1652 0, &new_fe_bh, parent_fe_bh, handle, 1677 0, &new_fe_bh, parent_fe_bh, handle,
1653 inode_ac); 1678 inode_ac);
@@ -1663,6 +1688,12 @@ static int ocfs2_symlink(struct inode *dir,
1663 u32 offset = 0; 1688 u32 offset = 0;
1664 1689
1665 inode->i_op = &ocfs2_symlink_inode_operations; 1690 inode->i_op = &ocfs2_symlink_inode_operations;
1691 if (vfs_dq_alloc_space_nodirty(inode,
1692 ocfs2_clusters_to_bytes(osb->sb, 1))) {
1693 status = -EDQUOT;
1694 goto bail;
1695 }
1696 did_quota = 1;
1666 status = ocfs2_add_inode_data(osb, inode, &offset, 1, 0, 1697 status = ocfs2_add_inode_data(osb, inode, &offset, 1, 0,
1667 new_fe_bh, 1698 new_fe_bh,
1668 handle, data_ac, NULL, 1699 handle, data_ac, NULL,
@@ -1728,6 +1759,11 @@ static int ocfs2_symlink(struct inode *dir,
1728 dentry->d_op = &ocfs2_dentry_ops; 1759 dentry->d_op = &ocfs2_dentry_ops;
1729 d_instantiate(dentry, inode); 1760 d_instantiate(dentry, inode);
1730bail: 1761bail:
1762 if (status < 0 && did_quota)
1763 vfs_dq_free_space_nodirty(inode,
1764 ocfs2_clusters_to_bytes(osb->sb, 1));
1765 if (status < 0 && did_quota_inode)
1766 vfs_dq_free_inode(inode);
1731 if (handle) 1767 if (handle)
1732 ocfs2_commit_trans(osb, handle); 1768 ocfs2_commit_trans(osb, handle);
1733 1769