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.c126
1 files changed, 57 insertions, 69 deletions
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 8a13226eb1a2..b6fa9eb2d298 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -42,7 +42,6 @@
42#include <linux/highmem.h> 42#include <linux/highmem.h>
43#include <linux/quotaops.h> 43#include <linux/quotaops.h>
44 44
45#define MLOG_MASK_PREFIX ML_NAMEI
46#include <cluster/masklog.h> 45#include <cluster/masklog.h>
47 46
48#include "ocfs2.h" 47#include "ocfs2.h"
@@ -63,6 +62,7 @@
63#include "uptodate.h" 62#include "uptodate.h"
64#include "xattr.h" 63#include "xattr.h"
65#include "acl.h" 64#include "acl.h"
65#include "ocfs2_trace.h"
66 66
67#include "buffer_head_io.h" 67#include "buffer_head_io.h"
68 68
@@ -106,17 +106,15 @@ static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry,
106 struct dentry *ret; 106 struct dentry *ret;
107 struct ocfs2_inode_info *oi; 107 struct ocfs2_inode_info *oi;
108 108
109 mlog(0, "(0x%p, 0x%p, '%.*s')\n", dir, dentry, 109 trace_ocfs2_lookup(dir, dentry, dentry->d_name.len,
110 dentry->d_name.len, dentry->d_name.name); 110 dentry->d_name.name,
111 (unsigned long long)OCFS2_I(dir)->ip_blkno, 0);
111 112
112 if (dentry->d_name.len > OCFS2_MAX_FILENAME_LEN) { 113 if (dentry->d_name.len > OCFS2_MAX_FILENAME_LEN) {
113 ret = ERR_PTR(-ENAMETOOLONG); 114 ret = ERR_PTR(-ENAMETOOLONG);
114 goto bail; 115 goto bail;
115 } 116 }
116 117
117 mlog(0, "find name %.*s in directory %llu\n", dentry->d_name.len,
118 dentry->d_name.name, (unsigned long long)OCFS2_I(dir)->ip_blkno);
119
120 status = ocfs2_inode_lock_nested(dir, NULL, 0, OI_LS_PARENT); 118 status = ocfs2_inode_lock_nested(dir, NULL, 0, OI_LS_PARENT);
121 if (status < 0) { 119 if (status < 0) {
122 if (status != -ENOENT) 120 if (status != -ENOENT)
@@ -182,7 +180,7 @@ bail_unlock:
182 180
183bail: 181bail:
184 182
185 mlog(0, "%p\n", ret); 183 trace_ocfs2_lookup_ret(ret);
186 184
187 return ret; 185 return ret;
188} 186}
@@ -235,9 +233,9 @@ static int ocfs2_mknod(struct inode *dir,
235 sigset_t oldset; 233 sigset_t oldset;
236 int did_block_signals = 0; 234 int did_block_signals = 0;
237 235
238 mlog(0, "(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, 236 trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name,
239 (unsigned long)dev, dentry->d_name.len, 237 (unsigned long long)OCFS2_I(dir)->ip_blkno,
240 dentry->d_name.name); 238 (unsigned long)dev, mode);
241 239
242 dquot_initialize(dir); 240 dquot_initialize(dir);
243 241
@@ -354,10 +352,6 @@ static int ocfs2_mknod(struct inode *dir,
354 goto leave; 352 goto leave;
355 did_quota_inode = 1; 353 did_quota_inode = 1;
356 354
357 mlog(0, "(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry,
358 inode->i_mode, (unsigned long)dev, dentry->d_name.len,
359 dentry->d_name.name);
360
361 /* do the real work now. */ 355 /* do the real work now. */
362 status = ocfs2_mknod_locked(osb, dir, inode, dev, 356 status = ocfs2_mknod_locked(osb, dir, inode, dev,
363 &new_fe_bh, parent_fe_bh, handle, 357 &new_fe_bh, parent_fe_bh, handle,
@@ -436,9 +430,6 @@ leave:
436 if (did_block_signals) 430 if (did_block_signals)
437 ocfs2_unblock_signals(&oldset); 431 ocfs2_unblock_signals(&oldset);
438 432
439 if (status == -ENOSPC)
440 mlog(0, "Disk is full\n");
441
442 brelse(new_fe_bh); 433 brelse(new_fe_bh);
443 brelse(parent_fe_bh); 434 brelse(parent_fe_bh);
444 kfree(si.name); 435 kfree(si.name);
@@ -617,8 +608,8 @@ static int ocfs2_mkdir(struct inode *dir,
617{ 608{
618 int ret; 609 int ret;
619 610
620 mlog(0, "(0x%p, 0x%p, %d, '%.*s')\n", dir, dentry, mode, 611 trace_ocfs2_mkdir(dir, dentry, dentry->d_name.len, dentry->d_name.name,
621 dentry->d_name.len, dentry->d_name.name); 612 OCFS2_I(dir)->ip_blkno, mode);
622 ret = ocfs2_mknod(dir, dentry, mode | S_IFDIR, 0); 613 ret = ocfs2_mknod(dir, dentry, mode | S_IFDIR, 0);
623 if (ret) 614 if (ret)
624 mlog_errno(ret); 615 mlog_errno(ret);
@@ -633,8 +624,8 @@ static int ocfs2_create(struct inode *dir,
633{ 624{
634 int ret; 625 int ret;
635 626
636 mlog(0, "(0x%p, 0x%p, %d, '%.*s')\n", dir, dentry, mode, 627 trace_ocfs2_create(dir, dentry, dentry->d_name.len, dentry->d_name.name,
637 dentry->d_name.len, dentry->d_name.name); 628 (unsigned long long)OCFS2_I(dir)->ip_blkno, mode);
638 ret = ocfs2_mknod(dir, dentry, mode | S_IFREG, 0); 629 ret = ocfs2_mknod(dir, dentry, mode | S_IFREG, 0);
639 if (ret) 630 if (ret)
640 mlog_errno(ret); 631 mlog_errno(ret);
@@ -656,9 +647,9 @@ static int ocfs2_link(struct dentry *old_dentry,
656 struct ocfs2_dir_lookup_result lookup = { NULL, }; 647 struct ocfs2_dir_lookup_result lookup = { NULL, };
657 sigset_t oldset; 648 sigset_t oldset;
658 649
659 mlog(0, "(inode=%lu, old='%.*s' new='%.*s')\n", inode->i_ino, 650 trace_ocfs2_link((unsigned long long)OCFS2_I(inode)->ip_blkno,
660 old_dentry->d_name.len, old_dentry->d_name.name, 651 old_dentry->d_name.len, old_dentry->d_name.name,
661 dentry->d_name.len, dentry->d_name.name); 652 dentry->d_name.len, dentry->d_name.name);
662 653
663 if (S_ISDIR(inode->i_mode)) 654 if (S_ISDIR(inode->i_mode))
664 return -EPERM; 655 return -EPERM;
@@ -814,19 +805,17 @@ static int ocfs2_unlink(struct inode *dir,
814 struct ocfs2_dir_lookup_result lookup = { NULL, }; 805 struct ocfs2_dir_lookup_result lookup = { NULL, };
815 struct ocfs2_dir_lookup_result orphan_insert = { NULL, }; 806 struct ocfs2_dir_lookup_result orphan_insert = { NULL, };
816 807
817 mlog(0, "(0x%p, 0x%p, '%.*s')\n", dir, dentry, 808 trace_ocfs2_unlink(dir, dentry, dentry->d_name.len,
818 dentry->d_name.len, dentry->d_name.name); 809 dentry->d_name.name,
810 (unsigned long long)OCFS2_I(dir)->ip_blkno,
811 (unsigned long long)OCFS2_I(inode)->ip_blkno);
819 812
820 dquot_initialize(dir); 813 dquot_initialize(dir);
821 814
822 BUG_ON(dentry->d_parent->d_inode != dir); 815 BUG_ON(dentry->d_parent->d_inode != dir);
823 816
824 mlog(0, "ino = %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno); 817 if (inode == osb->root_inode)
825
826 if (inode == osb->root_inode) {
827 mlog(0, "Cannot delete the root directory\n");
828 return -EPERM; 818 return -EPERM;
829 }
830 819
831 status = ocfs2_inode_lock_nested(dir, &parent_node_bh, 1, 820 status = ocfs2_inode_lock_nested(dir, &parent_node_bh, 1,
832 OI_LS_PARENT); 821 OI_LS_PARENT);
@@ -848,9 +837,10 @@ static int ocfs2_unlink(struct inode *dir,
848 if (OCFS2_I(inode)->ip_blkno != blkno) { 837 if (OCFS2_I(inode)->ip_blkno != blkno) {
849 status = -ENOENT; 838 status = -ENOENT;
850 839
851 mlog(0, "ip_blkno %llu != dirent blkno %llu ip_flags = %x\n", 840 trace_ocfs2_unlink_noent(
852 (unsigned long long)OCFS2_I(inode)->ip_blkno, 841 (unsigned long long)OCFS2_I(inode)->ip_blkno,
853 (unsigned long long)blkno, OCFS2_I(inode)->ip_flags); 842 (unsigned long long)blkno,
843 OCFS2_I(inode)->ip_flags);
854 goto leave; 844 goto leave;
855 } 845 }
856 846
@@ -981,9 +971,8 @@ static int ocfs2_double_lock(struct ocfs2_super *osb,
981 struct buffer_head **tmpbh; 971 struct buffer_head **tmpbh;
982 struct inode *tmpinode; 972 struct inode *tmpinode;
983 973
984 mlog(0, "(inode1 = %llu, inode2 = %llu)\n", 974 trace_ocfs2_double_lock((unsigned long long)oi1->ip_blkno,
985 (unsigned long long)oi1->ip_blkno, 975 (unsigned long long)oi2->ip_blkno);
986 (unsigned long long)oi2->ip_blkno);
987 976
988 if (*bh1) 977 if (*bh1)
989 *bh1 = NULL; 978 *bh1 = NULL;
@@ -994,7 +983,6 @@ static int ocfs2_double_lock(struct ocfs2_super *osb,
994 if (oi1->ip_blkno != oi2->ip_blkno) { 983 if (oi1->ip_blkno != oi2->ip_blkno) {
995 if (oi1->ip_blkno < oi2->ip_blkno) { 984 if (oi1->ip_blkno < oi2->ip_blkno) {
996 /* switch id1 and id2 around */ 985 /* switch id1 and id2 around */
997 mlog(0, "switching them around...\n");
998 tmpbh = bh2; 986 tmpbh = bh2;
999 bh2 = bh1; 987 bh2 = bh1;
1000 bh1 = tmpbh; 988 bh1 = tmpbh;
@@ -1030,6 +1018,10 @@ static int ocfs2_double_lock(struct ocfs2_super *osb,
1030 mlog_errno(status); 1018 mlog_errno(status);
1031 } 1019 }
1032 1020
1021 trace_ocfs2_double_lock_end(
1022 (unsigned long long)OCFS2_I(inode1)->ip_blkno,
1023 (unsigned long long)OCFS2_I(inode2)->ip_blkno);
1024
1033bail: 1025bail:
1034 if (status) 1026 if (status)
1035 mlog_errno(status); 1027 mlog_errno(status);
@@ -1074,10 +1066,9 @@ static int ocfs2_rename(struct inode *old_dir,
1074 /* At some point it might be nice to break this function up a 1066 /* At some point it might be nice to break this function up a
1075 * bit. */ 1067 * bit. */
1076 1068
1077 mlog(0, "(0x%p, 0x%p, 0x%p, 0x%p, from='%.*s' to='%.*s')\n", 1069 trace_ocfs2_rename(old_dir, old_dentry, new_dir, new_dentry,
1078 old_dir, old_dentry, new_dir, new_dentry, 1070 old_dentry->d_name.len, old_dentry->d_name.name,
1079 old_dentry->d_name.len, old_dentry->d_name.name, 1071 new_dentry->d_name.len, new_dentry->d_name.name);
1080 new_dentry->d_name.len, new_dentry->d_name.name);
1081 1072
1082 dquot_initialize(old_dir); 1073 dquot_initialize(old_dir);
1083 dquot_initialize(new_dir); 1074 dquot_initialize(new_dir);
@@ -1234,16 +1225,15 @@ static int ocfs2_rename(struct inode *old_dir,
1234 if (!new_inode) { 1225 if (!new_inode) {
1235 status = -EACCES; 1226 status = -EACCES;
1236 1227
1237 mlog(0, "We found an inode for name %.*s but VFS " 1228 trace_ocfs2_rename_target_exists(new_dentry->d_name.len,
1238 "didn't give us one.\n", new_dentry->d_name.len, 1229 new_dentry->d_name.name);
1239 new_dentry->d_name.name);
1240 goto bail; 1230 goto bail;
1241 } 1231 }
1242 1232
1243 if (OCFS2_I(new_inode)->ip_blkno != newfe_blkno) { 1233 if (OCFS2_I(new_inode)->ip_blkno != newfe_blkno) {
1244 status = -EACCES; 1234 status = -EACCES;
1245 1235
1246 mlog(0, "Inode %llu and dir %llu disagree. flags = %x\n", 1236 trace_ocfs2_rename_disagree(
1247 (unsigned long long)OCFS2_I(new_inode)->ip_blkno, 1237 (unsigned long long)OCFS2_I(new_inode)->ip_blkno,
1248 (unsigned long long)newfe_blkno, 1238 (unsigned long long)newfe_blkno,
1249 OCFS2_I(new_inode)->ip_flags); 1239 OCFS2_I(new_inode)->ip_flags);
@@ -1266,8 +1256,7 @@ static int ocfs2_rename(struct inode *old_dir,
1266 1256
1267 newfe = (struct ocfs2_dinode *) newfe_bh->b_data; 1257 newfe = (struct ocfs2_dinode *) newfe_bh->b_data;
1268 1258
1269 mlog(0, "aha rename over existing... new_blkno=%llu " 1259 trace_ocfs2_rename_over_existing(
1270 "newfebh=%p bhblocknr=%llu\n",
1271 (unsigned long long)newfe_blkno, newfe_bh, newfe_bh ? 1260 (unsigned long long)newfe_blkno, newfe_bh, newfe_bh ?
1272 (unsigned long long)newfe_bh->b_blocknr : 0ULL); 1261 (unsigned long long)newfe_bh->b_blocknr : 0ULL);
1273 1262
@@ -1509,9 +1498,8 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb,
1509 * write i_size + 1 bytes. */ 1498 * write i_size + 1 bytes. */
1510 blocks = (bytes_left + sb->s_blocksize - 1) >> sb->s_blocksize_bits; 1499 blocks = (bytes_left + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
1511 1500
1512 mlog(0, "i_blocks = %llu, i_size = %llu, blocks = %d\n", 1501 trace_ocfs2_create_symlink_data((unsigned long long)inode->i_blocks,
1513 (unsigned long long)inode->i_blocks, 1502 i_size_read(inode), blocks);
1514 i_size_read(inode), blocks);
1515 1503
1516 /* Sanity check -- make sure we're going to fit. */ 1504 /* Sanity check -- make sure we're going to fit. */
1517 if (bytes_left > 1505 if (bytes_left >
@@ -1619,8 +1607,8 @@ static int ocfs2_symlink(struct inode *dir,
1619 sigset_t oldset; 1607 sigset_t oldset;
1620 int did_block_signals = 0; 1608 int did_block_signals = 0;
1621 1609
1622 mlog(0, "(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir, 1610 trace_ocfs2_symlink_begin(dir, dentry, symname,
1623 dentry, symname, dentry->d_name.len, dentry->d_name.name); 1611 dentry->d_name.len, dentry->d_name.name);
1624 1612
1625 dquot_initialize(dir); 1613 dquot_initialize(dir);
1626 1614
@@ -1722,9 +1710,10 @@ static int ocfs2_symlink(struct inode *dir,
1722 goto bail; 1710 goto bail;
1723 did_quota_inode = 1; 1711 did_quota_inode = 1;
1724 1712
1725 mlog(0, "(0x%p, 0x%p, %d, '%.*s')\n", dir, dentry, 1713 trace_ocfs2_symlink_create(dir, dentry, dentry->d_name.len,
1726 inode->i_mode, dentry->d_name.len, 1714 dentry->d_name.name,
1727 dentry->d_name.name); 1715 (unsigned long long)OCFS2_I(dir)->ip_blkno,
1716 inode->i_mode);
1728 1717
1729 status = ocfs2_mknod_locked(osb, dir, inode, 1718 status = ocfs2_mknod_locked(osb, dir, inode,
1730 0, &new_fe_bh, parent_fe_bh, handle, 1719 0, &new_fe_bh, parent_fe_bh, handle,
@@ -1870,8 +1859,7 @@ static int ocfs2_blkno_stringify(u64 blkno, char *name)
1870 goto bail; 1859 goto bail;
1871 } 1860 }
1872 1861
1873 mlog(0, "built filename '%s' for orphan dir (len=%d)\n", name, 1862 trace_ocfs2_blkno_stringify(blkno, name, namelen);
1874 namelen);
1875 1863
1876 status = 0; 1864 status = 0;
1877bail: 1865bail:
@@ -2007,7 +1995,8 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
2007 struct ocfs2_dinode *orphan_fe; 1995 struct ocfs2_dinode *orphan_fe;
2008 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data; 1996 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;
2009 1997
2010 mlog(0, "(inode->i_ino = %lu)\n", inode->i_ino); 1998 trace_ocfs2_orphan_add_begin(
1999 (unsigned long long)OCFS2_I(inode)->ip_blkno);
2011 2000
2012 status = ocfs2_read_inode_block(orphan_dir_inode, &orphan_dir_bh); 2001 status = ocfs2_read_inode_block(orphan_dir_inode, &orphan_dir_bh);
2013 if (status < 0) { 2002 if (status < 0) {
@@ -2066,8 +2055,8 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
2066 2055
2067 ocfs2_journal_dirty(handle, fe_bh); 2056 ocfs2_journal_dirty(handle, fe_bh);
2068 2057
2069 mlog(0, "Inode %llu orphaned in slot %d\n", 2058 trace_ocfs2_orphan_add_end((unsigned long long)OCFS2_I(inode)->ip_blkno,
2070 (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num); 2059 osb->slot_num);
2071 2060
2072leave: 2061leave:
2073 brelse(orphan_dir_bh); 2062 brelse(orphan_dir_bh);
@@ -2095,9 +2084,9 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
2095 goto leave; 2084 goto leave;
2096 } 2085 }
2097 2086
2098 mlog(0, "removing '%s' from orphan dir %llu (namelen=%d)\n", 2087 trace_ocfs2_orphan_del(
2099 name, (unsigned long long)OCFS2_I(orphan_dir_inode)->ip_blkno, 2088 (unsigned long long)OCFS2_I(orphan_dir_inode)->ip_blkno,
2100 OCFS2_ORPHAN_NAMELEN); 2089 name, OCFS2_ORPHAN_NAMELEN);
2101 2090
2102 /* find it's spot in the orphan directory */ 2091 /* find it's spot in the orphan directory */
2103 status = ocfs2_find_entry(name, OCFS2_ORPHAN_NAMELEN, orphan_dir_inode, 2092 status = ocfs2_find_entry(name, OCFS2_ORPHAN_NAMELEN, orphan_dir_inode,
@@ -2331,9 +2320,6 @@ leave:
2331 iput(orphan_dir); 2320 iput(orphan_dir);
2332 } 2321 }
2333 2322
2334 if (status == -ENOSPC)
2335 mlog(0, "Disk is full\n");
2336
2337 if ((status < 0) && inode) { 2323 if ((status < 0) && inode) {
2338 clear_nlink(inode); 2324 clear_nlink(inode);
2339 iput(inode); 2325 iput(inode);
@@ -2368,8 +2354,10 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,
2368 struct buffer_head *di_bh = NULL; 2354 struct buffer_head *di_bh = NULL;
2369 struct ocfs2_dir_lookup_result lookup = { NULL, }; 2355 struct ocfs2_dir_lookup_result lookup = { NULL, };
2370 2356
2371 mlog(0, "(0x%p, 0x%p, %.*s')\n", dir, dentry, 2357 trace_ocfs2_mv_orphaned_inode_to_new(dir, dentry,
2372 dentry->d_name.len, dentry->d_name.name); 2358 dentry->d_name.len, dentry->d_name.name,
2359 (unsigned long long)OCFS2_I(dir)->ip_blkno,
2360 (unsigned long long)OCFS2_I(inode)->ip_blkno);
2373 2361
2374 status = ocfs2_inode_lock(dir, &parent_di_bh, 1); 2362 status = ocfs2_inode_lock(dir, &parent_di_bh, 1);
2375 if (status < 0) { 2363 if (status < 0) {