22 #include <linux/ctype.h>
49 static inline void free_ea_wmap(
struct inode *
inode)
84 struct inode *iplist[2];
87 jfs_info(
"jfs_create: dip:0x%p name:%s", dip, dentry->
d_name.name);
118 rc = jfs_init_security(tid, ip, dip, &dentry->
d_name);
125 jfs_err(
"jfs_create: dtSearch returned %d", rc);
133 tblk->
u.
ixpxd = JFS_IP(ip)->ixpxd;
150 jfs_err(
"jfs_create: dtInsert returned -EIO");
161 mark_inode_dirty(ip);
165 mark_inode_dirty(dip);
167 rc =
txCommit(tid, 2, &iplist[0], 0);
208 static int jfs_mkdir(
struct inode *dip,
struct dentry *dentry,
umode_t mode)
212 struct inode *ip =
NULL;
216 struct inode *iplist[2];
219 jfs_info(
"jfs_mkdir: dip:0x%p name:%s", dip, dentry->
d_name.name);
250 rc = jfs_init_security(tid, ip, dip, &dentry->
d_name);
257 jfs_err(
"jfs_mkdir: dtSearch returned %d", rc);
265 tblk->
u.
ixpxd = JFS_IP(ip)->ixpxd;
282 jfs_err(
"jfs_mkdir: dtInsert returned -EIO");
293 mark_inode_dirty(ip);
298 mark_inode_dirty(dip);
300 rc =
txCommit(tid, 2, &iplist[0], 0);
345 static int jfs_rmdir(
struct inode *dip,
struct dentry *dentry)
349 struct inode *ip = dentry->
d_inode;
352 struct inode *iplist[2];
355 jfs_info(
"jfs_rmdir: dip:0x%p name:%s", dip, dentry->
d_name.name);
388 jfs_err(
"jfs_rmdir: dtDelete returned %d", rc);
402 inode_dec_link_count(dip);
410 txEA(tid, ip, &JFS_IP(ip)->ea,
NULL);
412 JFS_IP(ip)->ea.flag = 0;
417 txEA(tid, ip, &JFS_IP(ip)->acl,
NULL);
419 JFS_IP(ip)->acl.flag = 0;
423 mark_inode_dirty(ip);
425 rc =
txCommit(tid, 2, &iplist[0], 0);
471 static int jfs_unlink(
struct inode *dip,
struct dentry *dentry)
475 struct inode *ip = dentry->
d_inode;
478 struct inode *iplist[2];
483 jfs_info(
"jfs_unlink: dip:0x%p name:%s", dip, dentry->
d_name.name);
507 jfs_err(
"jfs_unlink: dtDelete returned %d", rc);
520 mark_inode_dirty(dip);
523 inode_dec_link_count(ip);
531 if ((new_size = commitZeroLink(tid, ip)) < 0) {
559 rc =
txCommit(tid, 2, &iplist[0], commit_flag);
566 while (new_size && (rc == 0)) {
626 static s64 commitZeroLink(
tid_t tid,
struct inode *ip)
631 jfs_info(
"commitZeroLink: tid = %d, ip = 0x%p", tid, ip);
660 txEA(tid, ip, &JFS_IP(ip)->ea,
NULL);
667 txEA(tid, ip, &JFS_IP(ip)->acl,
NULL);
696 jfs_info(
"jfs_free_zero_link: ip = 0x%p", ip);
729 pxdlock = (
struct pxd_lock *) & maplock;
749 pxdlock = (
struct pxd_lock *) & maplock;
789 static int jfs_link(
struct dentry *old_dentry,
790 struct inode *dir,
struct dentry *dentry)
794 struct inode *ip = old_dentry->
d_inode;
798 struct inode *iplist[2];
830 mark_inode_dirty(dir);
835 rc =
txCommit(tid, 2, &iplist[0], 0);
874 static int jfs_symlink(
struct inode *dip,
struct dentry *dentry,
883 struct inode *ip = dentry->
d_inode;
886 int bmask = 0, xsize;
892 struct inode *iplist[2];
894 jfs_info(
"jfs_symlink: dip:0x%p name:%s", dip, name);
923 rc = jfs_init_security(tid, ip, dip, &dentry->
d_name);
930 tblk->
u.
ixpxd = JFS_IP(ip)->ixpxd;
950 i_fastsymlink = JFS_IP(ip)->i_inline;
951 memcpy(i_fastsymlink, name, ssize);
958 if (ssize >
sizeof (JFS_IP(ip)->
i_inline))
961 jfs_info(
"jfs_symlink: fast symlink added ssize:%d name:%s ",
968 jfs_info(
"jfs_symlink: allocate extent ip:0x%p", ip);
979 bmask = JFS_SBI(sb)->bsize - 1;
980 xsize = (ssize +
bmask) & ~bmask;
982 xlen = xsize >> JFS_SBI(sb)->l2bsize;
983 if ((rc =
xtInsert(tid, ip, 0, 0, xlen, &xaddr, 0))) {
1004 xaddr += JFS_SBI(sb)->nbperpage;
1024 mark_inode_dirty(ip);
1027 mark_inode_dirty(dip);
1034 rc =
txCommit(tid, 2, &iplist[0], 0);
1054 jfs_info(
"jfs_symlink: rc:%d", rc);
1064 static int jfs_rename(
struct inode *old_dir,
struct dentry *old_dentry,
1065 struct inode *new_dir,
struct dentry *new_dentry)
1070 struct inode *new_ip;
1072 struct inode *old_ip;
1079 struct inode *iplist[4];
1086 new_dentry->
d_name.name);
1104 if (rc || (ino != old_ip->
i_ino)) {
1114 if ((!new_ip) || (ino != new_ip->
i_ino)) {
1118 }
else if (rc != -
ENOENT)
1133 }
else if (new_ip) {
1152 if (old_dir != new_dir)
1162 ino = new_ip->
i_ino;
1163 rc =
dtModify(tid, new_dir, &new_dname, &ino,
1172 if (old_dir != new_dir)
1179 "jfs_rename: new_ip->i_nlink != 0");
1184 tblk->
u.
ip = new_ip;
1185 }
else if (new_ip->
i_nlink == 0) {
1188 if ((new_size = commitZeroLink(tid, new_ip)) < 0) {
1195 tblk->
u.
ip = new_ip;
1198 mark_inode_dirty(new_ip);
1207 jfs_err(
"jfs_rename didn't expect dtSearch to fail "
1212 ino = old_ip->
i_ino;
1216 jfs_err(
"jfs_rename: dtInsert returned -EIO");
1226 ino = old_ip->
i_ino;
1229 jfs_err(
"jfs_rename did not expect dtDelete to return rc = %d",
1236 if (old_dir != new_dir) {
1241 JFS_IP(old_ip)->i_dtroot.header.idotdot =
1245 tlck =
txLock(tid, old_ip,
1246 (
struct metapage *) &JFS_IP(old_ip)->bxflag,
1249 ASSERT(dtlck->index == 0);
1250 lv = & dtlck->lv[0];
1261 mark_inode_dirty(old_ip);
1264 mark_inode_dirty(new_dir);
1268 iplist[ipcount++] = old_ip;
1270 iplist[ipcount++] = new_ip;
1271 iplist[ipcount++] = old_dir;
1273 if (old_dir != new_dir) {
1274 iplist[ipcount++] = new_dir;
1276 mark_inode_dirty(old_dir);
1289 rc =
txCommit(tid, ipcount, iplist, commit_flag);
1295 if (old_dir != new_dir)
1300 while (new_size && (rc == 0)) {
1312 if (new_ip && (new_ip->
i_nlink == 0))
1332 jfs_info(
"jfs_rename: returning %d", rc);
1342 static int jfs_mknod(
struct inode *dir,
struct dentry *dentry,
1350 struct inode *iplist[2];
1355 if (!new_valid_dev(rdev))
1370 jfs_ip = JFS_IP(ip);
1381 rc = jfs_init_security(tid, ip, dir, &dentry->
d_name);
1395 tblk->
u.
ixpxd = JFS_IP(ip)->ixpxd;
1404 jfs_ip->
dev = new_encode_dev(rdev);
1407 mark_inode_dirty(ip);
1411 mark_inode_dirty(dir);
1435 jfs_info(
"jfs_mknod: returning %d", rc);
1439 static struct dentry *jfs_lookup(
struct inode *dip,
struct dentry *dentry,
unsigned int flags)
1456 jfs_err(
"jfs_lookup: dtSearch returned %d", rc);
1461 jfs_err(
"jfs_lookup: iget failed on inum %d", (
uint)inum);
1467 static struct inode *jfs_nfs_get_inode(
struct super_block *sb,
1470 struct inode *
inode;
1476 return ERR_CAST(inode);
1487 int fh_len,
int fh_type)
1494 int fh_len,
int fh_type)
1511 .create = jfs_create,
1512 .lookup = jfs_lookup,
1514 .unlink = jfs_unlink,
1515 .symlink = jfs_symlink,
1519 .rename = jfs_rename,
1525 #ifdef CONFIG_JFS_POSIX_ACL
1535 #ifdef CONFIG_COMPAT
1541 static int jfs_ci_hash(
const struct dentry *dir,
const struct inode *inode,
1548 for (i=0; i < this->
len; i++)
1549 hash = partial_name_hash(
tolower(this->name[i]), hash);
1550 this->hash = end_name_hash(hash);
1555 static int jfs_ci_compare(
const struct dentry *parent,
1556 const struct inode *pinode,
1557 const struct dentry *dentry,
const struct inode *inode,
1558 unsigned int len,
const char *
str,
const struct qstr *name)
1562 if (len != name->len)
1564 for (i=0; i < len; i++) {
1573 static int jfs_ci_revalidate(
struct dentry *dentry,
unsigned int flags)
1607 .d_hash = jfs_ci_hash,
1608 .d_compare = jfs_ci_compare,
1609 .d_revalidate = jfs_ci_revalidate,