2 * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
4 * Trivial changes by Alan Cox to remove EHASHCOLLISION for compatibility
7 * Rights granted to Hans Reiser to redistribute under other terms providing
8 * he accepts all liability including but not limited to patent, fitness
9 * for purpose, and direct or indirect claims arising from failure to perform.
14 #include <linux/config.h>
15 #include <linux/time.h>
16 #include <linux/bitops.h>
17 #include <linux/reiserfs_fs.h>
18 #include <linux/reiserfs_acl.h>
19 #include <linux/reiserfs_xattr.h>
20 #include <linux/smp_lock.h>
21 #include <linux/quotaops.h>
23 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { i->i_nlink++; if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; }
24 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) i->i_nlink--;
26 // directory item contains array of entry headers. This performs
27 // binary search through that array
28 static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off)
30 struct item_head *ih = de->de_ih;
31 struct reiserfs_de_head *deh = de->de_deh;
32 int rbound, lbound, j;
35 rbound = I_ENTRY_COUNT(ih) - 1;
37 for (j = (rbound + lbound) / 2; lbound <= rbound;
38 j = (rbound + lbound) / 2) {
39 if (off < deh_offset(deh + j)) {
43 if (off > deh_offset(deh + j)) {
47 // this is not name found, but matched third key component
52 de->de_entry_num = lbound;
53 return NAME_NOT_FOUND;
56 // comment? maybe something like set de to point to what the path points to?
57 static inline void set_de_item_location(struct reiserfs_dir_entry *de,
60 de->de_bh = get_last_bh(path);
61 de->de_ih = get_ih(path);
62 de->de_deh = B_I_DEH(de->de_bh, de->de_ih);
63 de->de_item_num = PATH_LAST_POSITION(path);
66 // de_bh, de_ih, de_deh (points to first element of array), de_item_num is set
67 inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de)
69 struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num;
71 if (de->de_entry_num >= ih_entry_count(de->de_ih))
74 de->de_entrylen = entry_length(de->de_bh, de->de_ih, de->de_entry_num);
75 de->de_namelen = de->de_entrylen - (de_with_sd(deh) ? SD_SIZE : 0);
76 de->de_name = B_I_PITEM(de->de_bh, de->de_ih) + deh_location(deh);
77 if (de->de_name[de->de_namelen - 1] == 0)
78 de->de_namelen = strlen(de->de_name);
81 // what entry points to
82 static inline void set_de_object_key(struct reiserfs_dir_entry *de)
84 if (de->de_entry_num >= ih_entry_count(de->de_ih))
86 de->de_dir_id = deh_dir_id(&(de->de_deh[de->de_entry_num]));
87 de->de_objectid = deh_objectid(&(de->de_deh[de->de_entry_num]));
90 static inline void store_de_entry_key(struct reiserfs_dir_entry *de)
92 struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num;
94 if (de->de_entry_num >= ih_entry_count(de->de_ih))
97 /* store key of the found entry */
98 de->de_entry_key.version = KEY_FORMAT_3_5;
99 de->de_entry_key.on_disk_key.k_dir_id =
100 le32_to_cpu(de->de_ih->ih_key.k_dir_id);
101 de->de_entry_key.on_disk_key.k_objectid =
102 le32_to_cpu(de->de_ih->ih_key.k_objectid);
103 set_cpu_key_k_offset(&(de->de_entry_key), deh_offset(deh));
104 set_cpu_key_k_type(&(de->de_entry_key), TYPE_DIRENTRY);
107 /* We assign a key to each directory item, and place multiple entries
108 in a single directory item. A directory item has a key equal to the
109 key of the first directory entry in it.
111 This function first calls search_by_key, then, if item whose first
112 entry matches is not found it looks for the entry inside directory
113 item found by search_by_key. Fills the path to the entry, and to the
114 entry position in the item
118 /* The function is NOT SCHEDULE-SAFE! */
119 int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
120 struct path *path, struct reiserfs_dir_entry *de)
124 retval = search_item(sb, key, path);
127 if (!PATH_LAST_POSITION(path)) {
129 "vs-7000: search_by_entry_key: search_by_key returned item position == 0");
133 PATH_LAST_POSITION(path)--;
144 "vs-7002: search_by_entry_key: no path to here");
148 set_de_item_location(de, path);
150 #ifdef CONFIG_REISERFS_CHECK
151 if (!is_direntry_le_ih(de->de_ih) ||
152 COMP_SHORT_KEYS(&(de->de_ih->ih_key), key)) {
153 print_block(de->de_bh, 0, -1, -1);
155 "vs-7005: search_by_entry_key: found item %h is not directory item or "
156 "does not belong to the same directory as key %K",
159 #endif /* CONFIG_REISERFS_CHECK */
161 /* binary search in directory item by third componen t of the
162 key. sets de->de_entry_num of de */
163 retval = bin_search_in_dir_item(de, cpu_key_k_offset(key));
164 path->pos_in_item = de->de_entry_num;
165 if (retval != NAME_NOT_FOUND) {
166 // ugly, but rename needs de_bh, de_deh, de_name, de_namelen, de_objectid set
167 set_de_name_and_namelen(de);
168 set_de_object_key(de);
173 /* Keyed 32-bit hash function using TEA in a Davis-Meyer function */
175 /* The third component is hashed, and you can choose from more than
176 one hash function. Per directory hashes are not yet implemented
177 but are thought about. This function should be moved to hashes.c
178 Jedi, please do so. -Hans */
180 static __u32 get_third_component(struct super_block *s,
181 const char *name, int len)
185 if (!len || (len == 1 && name[0] == '.'))
187 if (len == 2 && name[0] == '.' && name[1] == '.')
188 return DOT_DOT_OFFSET;
190 res = REISERFS_SB(s)->s_hash_function(name, len);
192 // take bits from 7-th to 30-th including both bounds
193 res = GET_HASH_VALUE(res);
195 // needed to have no names before "." and ".." those have hash
196 // value == 0 and generation conters 1 and 2 accordingly
198 return res + MAX_GENERATION_NUMBER;
201 static int reiserfs_match(struct reiserfs_dir_entry *de,
202 const char *name, int namelen)
204 int retval = NAME_NOT_FOUND;
206 if ((namelen == de->de_namelen) &&
207 !memcmp(de->de_name, name, de->de_namelen))
209 (de_visible(de->de_deh + de->de_entry_num) ? NAME_FOUND :
210 NAME_FOUND_INVISIBLE);
215 /* de's de_bh, de_ih, de_deh, de_item_num, de_entry_num are set already */
217 /* used when hash collisions exist */
219 static int linear_search_in_dir_item(struct cpu_key *key,
220 struct reiserfs_dir_entry *de,
221 const char *name, int namelen)
223 struct reiserfs_de_head *deh = de->de_deh;
227 i = de->de_entry_num;
229 if (i == I_ENTRY_COUNT(de->de_ih) ||
230 GET_HASH_VALUE(deh_offset(deh + i)) !=
231 GET_HASH_VALUE(cpu_key_k_offset(key))) {
235 RFALSE(de->de_deh != B_I_DEH(de->de_bh, de->de_ih),
236 "vs-7010: array of entry headers not found");
240 for (; i >= 0; i--, deh--) {
241 if (GET_HASH_VALUE(deh_offset(deh)) !=
242 GET_HASH_VALUE(cpu_key_k_offset(key))) {
243 // hash value does not match, no need to check whole name
244 return NAME_NOT_FOUND;
247 /* mark, that this generation number is used */
248 if (de->de_gen_number_bit_string)
249 set_bit(GET_GENERATION_NUMBER(deh_offset(deh)),
250 (unsigned long *)de->de_gen_number_bit_string);
252 // calculate pointer to name and namelen
253 de->de_entry_num = i;
254 set_de_name_and_namelen(de);
257 reiserfs_match(de, name, namelen)) != NAME_NOT_FOUND) {
258 // de's de_name, de_namelen, de_recordlen are set. Fill the rest:
260 // key of pointed object
261 set_de_object_key(de);
263 store_de_entry_key(de);
265 // retval can be NAME_FOUND or NAME_FOUND_INVISIBLE
270 if (GET_GENERATION_NUMBER(le_ih_k_offset(de->de_ih)) == 0)
271 /* we have reached left most entry in the node. In common we
272 have to go to the left neighbor, but if generation counter
273 is 0 already, we know for sure, that there is no name with
274 the same hash value */
275 // FIXME: this work correctly only because hash value can not
276 // be 0. Btw, in case of Yura's hash it is probably possible,
278 return NAME_NOT_FOUND;
280 RFALSE(de->de_item_num,
281 "vs-7015: two diritems of the same directory in one node?");
283 return GOTO_PREVIOUS_ITEM;
286 // may return NAME_FOUND, NAME_FOUND_INVISIBLE, NAME_NOT_FOUND
287 // FIXME: should add something like IOERROR
288 static int reiserfs_find_entry(struct inode *dir, const char *name, int namelen,
289 struct path *path_to_entry,
290 struct reiserfs_dir_entry *de)
292 struct cpu_key key_to_search;
295 if (namelen > REISERFS_MAX_NAME(dir->i_sb->s_blocksize))
296 return NAME_NOT_FOUND;
298 /* we will search for this key in the tree */
299 make_cpu_key(&key_to_search, dir,
300 get_third_component(dir->i_sb, name, namelen),
305 search_by_entry_key(dir->i_sb, &key_to_search,
307 if (retval == IO_ERROR) {
308 reiserfs_warning(dir->i_sb, "zam-7001: io error in %s",
313 /* compare names for all entries having given hash value */
315 linear_search_in_dir_item(&key_to_search, de, name,
317 if (retval != GOTO_PREVIOUS_ITEM) {
318 /* there is no need to scan directory anymore. Given entry found or does not exist */
319 path_to_entry->pos_in_item = de->de_entry_num;
323 /* there is left neighboring item of this directory and given entry can be there */
324 set_cpu_key_k_offset(&key_to_search,
325 le_ih_k_offset(de->de_ih) - 1);
326 pathrelse(path_to_entry);
331 static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
332 struct nameidata *nd)
335 struct inode *inode = NULL;
336 struct reiserfs_dir_entry de;
337 INITIALIZE_PATH(path_to_entry);
339 if (REISERFS_MAX_NAME(dir->i_sb->s_blocksize) < dentry->d_name.len)
340 return ERR_PTR(-ENAMETOOLONG);
342 reiserfs_write_lock(dir->i_sb);
343 de.de_gen_number_bit_string = NULL;
345 reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
346 &path_to_entry, &de);
347 pathrelse(&path_to_entry);
348 if (retval == NAME_FOUND) {
349 /* Hide the .reiserfs_priv directory */
350 if (reiserfs_xattrs(dir->i_sb) &&
351 !old_format_only(dir->i_sb) &&
352 REISERFS_SB(dir->i_sb)->priv_root &&
353 REISERFS_SB(dir->i_sb)->priv_root->d_inode &&
355 le32_to_cpu(INODE_PKEY
356 (REISERFS_SB(dir->i_sb)->priv_root->d_inode)->
358 reiserfs_write_unlock(dir->i_sb);
359 return ERR_PTR(-EACCES);
363 reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
364 if (!inode || IS_ERR(inode)) {
365 reiserfs_write_unlock(dir->i_sb);
366 return ERR_PTR(-EACCES);
369 /* Propogate the priv_object flag so we know we're in the priv tree */
370 if (is_reiserfs_priv_object(dir))
371 reiserfs_mark_inode_private(inode);
373 reiserfs_write_unlock(dir->i_sb);
374 if (retval == IO_ERROR) {
375 return ERR_PTR(-EIO);
379 return d_splice_alias(inode, dentry);
381 d_add(dentry, inode);
386 ** looks up the dentry of the parent directory for child.
387 ** taken from ext2_get_parent
389 struct dentry *reiserfs_get_parent(struct dentry *child)
392 struct inode *inode = NULL;
393 struct reiserfs_dir_entry de;
394 INITIALIZE_PATH(path_to_entry);
395 struct dentry *parent;
396 struct inode *dir = child->d_inode;
398 if (dir->i_nlink == 0) {
399 return ERR_PTR(-ENOENT);
401 de.de_gen_number_bit_string = NULL;
403 reiserfs_write_lock(dir->i_sb);
404 retval = reiserfs_find_entry(dir, "..", 2, &path_to_entry, &de);
405 pathrelse(&path_to_entry);
406 if (retval != NAME_FOUND) {
407 reiserfs_write_unlock(dir->i_sb);
408 return ERR_PTR(-ENOENT);
410 inode = reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
411 reiserfs_write_unlock(dir->i_sb);
413 if (!inode || IS_ERR(inode)) {
414 return ERR_PTR(-EACCES);
416 parent = d_alloc_anon(inode);
419 parent = ERR_PTR(-ENOMEM);
424 /* add entry to the directory (entry can be hidden).
426 insert definition of when hidden directories are used here -Hans
428 Does not mark dir inode dirty, do it after successesfull call to it */
430 static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
431 struct inode *dir, const char *name, int namelen,
432 struct inode *inode, int visible)
434 struct cpu_key entry_key;
435 struct reiserfs_de_head *deh;
436 INITIALIZE_PATH(path);
437 struct reiserfs_dir_entry de;
438 int bit_string[MAX_GENERATION_NUMBER / (sizeof(int) * 8) + 1];
440 char small_buf[32 + DEH_SIZE]; /* 48 bytes now and we avoid kmalloc
441 if we create file with short name */
443 int buflen, paste_size;
446 BUG_ON(!th->t_trans_id);
448 /* cannot allow items to be added into a busy deleted directory */
452 if (namelen > REISERFS_MAX_NAME(dir->i_sb->s_blocksize))
453 return -ENAMETOOLONG;
455 /* each entry has unique key. compose it */
456 make_cpu_key(&entry_key, dir,
457 get_third_component(dir->i_sb, name, namelen),
460 /* get memory for composing the entry */
461 buflen = DEH_SIZE + ROUND_UP(namelen);
462 if (buflen > sizeof(small_buf)) {
463 buffer = reiserfs_kmalloc(buflen, GFP_NOFS, dir->i_sb);
470 (get_inode_sd_version(dir) ==
471 STAT_DATA_V1) ? (DEH_SIZE + namelen) : buflen;
473 /* fill buffer : directory entry head, name[, dir objectid | , stat data | ,stat data, dir objectid ] */
474 deh = (struct reiserfs_de_head *)buffer;
475 deh->deh_location = 0; /* JDM Endian safe if 0 */
476 put_deh_offset(deh, cpu_key_k_offset(&entry_key));
477 deh->deh_state = 0; /* JDM Endian safe if 0 */
478 /* put key (ino analog) to de */
479 deh->deh_dir_id = INODE_PKEY(inode)->k_dir_id; /* safe: k_dir_id is le */
480 deh->deh_objectid = INODE_PKEY(inode)->k_objectid; /* safe: k_objectid is le */
483 memcpy((char *)(deh + 1), name, namelen);
484 /* padd by 0s to the 4 byte boundary */
485 padd_item((char *)(deh + 1), ROUND_UP(namelen), namelen);
487 /* entry is ready to be pasted into tree, set 'visibility' and 'stat data in entry' attributes */
488 mark_de_without_sd(deh);
489 visible ? mark_de_visible(deh) : mark_de_hidden(deh);
491 /* find the proper place for the new entry */
492 memset(bit_string, 0, sizeof(bit_string));
493 de.de_gen_number_bit_string = (char *)bit_string;
494 retval = reiserfs_find_entry(dir, name, namelen, &path, &de);
495 if (retval != NAME_NOT_FOUND) {
496 if (buffer != small_buf)
497 reiserfs_kfree(buffer, buflen, dir->i_sb);
500 if (retval == IO_ERROR) {
504 if (retval != NAME_FOUND) {
505 reiserfs_warning(dir->i_sb,
506 "zam-7002:%s: \"reiserfs_find_entry\" "
507 "has returned unexpected value (%d)",
508 __FUNCTION__, retval);
515 find_first_zero_bit((unsigned long *)bit_string,
516 MAX_GENERATION_NUMBER + 1);
517 if (gen_number > MAX_GENERATION_NUMBER) {
518 /* there is no free generation number */
519 reiserfs_warning(dir->i_sb,
520 "reiserfs_add_entry: Congratulations! we have got hash function screwed up");
521 if (buffer != small_buf)
522 reiserfs_kfree(buffer, buflen, dir->i_sb);
526 /* adjust offset of directory enrty */
527 put_deh_offset(deh, SET_GENERATION_NUMBER(deh_offset(deh), gen_number));
528 set_cpu_key_k_offset(&entry_key, deh_offset(deh));
530 /* update max-hash-collisions counter in reiserfs_sb_info */
531 PROC_INFO_MAX(th->t_super, max_hash_collisions, gen_number);
533 if (gen_number != 0) { /* we need to re-search for the insertion point */
534 if (search_by_entry_key(dir->i_sb, &entry_key, &path, &de) !=
536 reiserfs_warning(dir->i_sb,
537 "vs-7032: reiserfs_add_entry: "
538 "entry with this key (%K) already exists",
541 if (buffer != small_buf)
542 reiserfs_kfree(buffer, buflen, dir->i_sb);
548 /* perform the insertion of the entry that we have prepared */
550 reiserfs_paste_into_item(th, &path, &entry_key, dir, buffer,
552 if (buffer != small_buf)
553 reiserfs_kfree(buffer, buflen, dir->i_sb);
555 reiserfs_check_path(&path);
559 dir->i_size += paste_size;
560 dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
561 if (!S_ISDIR(inode->i_mode) && visible)
562 // reiserfs_mkdir or reiserfs_rename will do that by itself
563 reiserfs_update_sd(th, dir);
565 reiserfs_check_path(&path);
569 /* quota utility function, call if you've had to abort after calling
570 ** new_inode_init, and have not called reiserfs_new_inode yet.
571 ** This should only be called on inodes that do not have stat data
572 ** inserted into the tree yet.
574 static int drop_new_inode(struct inode *inode)
577 make_bad_inode(inode);
578 inode->i_flags |= S_NOQUOTA;
583 /* utility function that does setup for reiserfs_new_inode.
584 ** DQUOT_INIT needs lots of credits so it's better to have it
585 ** outside of a transaction, so we had to pull some bits of
586 ** reiserfs_new_inode out into this func.
588 static int new_inode_init(struct inode *inode, struct inode *dir, int mode)
591 /* the quota init calls have to know who to charge the quota to, so
592 ** we have to set uid and gid here
594 inode->i_uid = current->fsuid;
595 inode->i_mode = mode;
596 /* Make inode invalid - just in case we are going to drop it before
597 * the initialization happens */
598 INODE_PKEY(inode)->k_objectid = 0;
600 if (dir->i_mode & S_ISGID) {
601 inode->i_gid = dir->i_gid;
603 inode->i_mode |= S_ISGID;
605 inode->i_gid = current->fsgid;
611 static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode,
612 struct nameidata *nd)
616 /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
618 JOURNAL_PER_BALANCE_CNT * 2 +
619 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
620 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
621 struct reiserfs_transaction_handle th;
624 if (!(inode = new_inode(dir->i_sb))) {
627 new_inode_init(inode, dir, mode);
629 locked = reiserfs_cache_default_acl(dir);
631 reiserfs_write_lock(dir->i_sb);
634 reiserfs_write_lock_xattrs(dir->i_sb);
636 retval = journal_begin(&th, dir->i_sb, jbegin_count);
638 drop_new_inode(inode);
643 reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
649 reiserfs_write_unlock_xattrs(dir->i_sb);
653 inode->i_op = &reiserfs_file_inode_operations;
654 inode->i_fop = &reiserfs_file_operations;
655 inode->i_mapping->a_ops = &reiserfs_address_space_operations;
658 reiserfs_add_entry(&th, dir, dentry->d_name.name,
659 dentry->d_name.len, inode, 1 /*visible */ );
663 reiserfs_update_sd(&th, inode);
664 err = journal_end(&th, dir->i_sb, jbegin_count);
670 reiserfs_update_inode_transaction(inode);
671 reiserfs_update_inode_transaction(dir);
673 d_instantiate(dentry, inode);
674 retval = journal_end(&th, dir->i_sb, jbegin_count);
678 reiserfs_write_unlock_xattrs(dir->i_sb);
679 reiserfs_write_unlock(dir->i_sb);
683 static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
688 struct reiserfs_transaction_handle th;
689 /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
691 JOURNAL_PER_BALANCE_CNT * 3 +
692 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
693 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
696 if (!new_valid_dev(rdev))
699 if (!(inode = new_inode(dir->i_sb))) {
702 new_inode_init(inode, dir, mode);
704 locked = reiserfs_cache_default_acl(dir);
706 reiserfs_write_lock(dir->i_sb);
709 reiserfs_write_lock_xattrs(dir->i_sb);
711 retval = journal_begin(&th, dir->i_sb, jbegin_count);
713 drop_new_inode(inode);
718 reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
725 reiserfs_write_unlock_xattrs(dir->i_sb);
729 inode->i_op = &reiserfs_special_inode_operations;
730 init_special_inode(inode, inode->i_mode, rdev);
732 //FIXME: needed for block and char devices only
733 reiserfs_update_sd(&th, inode);
735 reiserfs_update_inode_transaction(inode);
736 reiserfs_update_inode_transaction(dir);
739 reiserfs_add_entry(&th, dir, dentry->d_name.name,
740 dentry->d_name.len, inode, 1 /*visible */ );
744 reiserfs_update_sd(&th, inode);
745 err = journal_end(&th, dir->i_sb, jbegin_count);
752 d_instantiate(dentry, inode);
753 retval = journal_end(&th, dir->i_sb, jbegin_count);
757 reiserfs_write_unlock_xattrs(dir->i_sb);
758 reiserfs_write_unlock(dir->i_sb);
762 static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
766 struct reiserfs_transaction_handle th;
767 /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
769 JOURNAL_PER_BALANCE_CNT * 3 +
770 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
771 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
774 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
775 /* set flag that new packing locality created and new blocks for the content * of that directory are not displaced yet */
776 REISERFS_I(dir)->new_packing_locality = 1;
778 mode = S_IFDIR | mode;
779 if (!(inode = new_inode(dir->i_sb))) {
782 new_inode_init(inode, dir, mode);
784 locked = reiserfs_cache_default_acl(dir);
786 reiserfs_write_lock(dir->i_sb);
788 reiserfs_write_lock_xattrs(dir->i_sb);
790 retval = journal_begin(&th, dir->i_sb, jbegin_count);
792 drop_new_inode(inode);
796 /* inc the link count now, so another writer doesn't overflow it while
797 ** we sleep later on.
799 INC_DIR_INODE_NLINK(dir)
801 retval = reiserfs_new_inode(&th, dir, mode, NULL /*symlink */ ,
802 old_format_only(dir->i_sb) ?
803 EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
811 reiserfs_write_unlock_xattrs(dir->i_sb);
815 reiserfs_update_inode_transaction(inode);
816 reiserfs_update_inode_transaction(dir);
818 inode->i_op = &reiserfs_dir_inode_operations;
819 inode->i_fop = &reiserfs_dir_operations;
821 // note, _this_ add_entry will not update dir's stat data
823 reiserfs_add_entry(&th, dir, dentry->d_name.name,
824 dentry->d_name.len, inode, 1 /*visible */ );
828 DEC_DIR_INODE_NLINK(dir);
829 reiserfs_update_sd(&th, inode);
830 err = journal_end(&th, dir->i_sb, jbegin_count);
836 // the above add_entry did not update dir's stat data
837 reiserfs_update_sd(&th, dir);
839 d_instantiate(dentry, inode);
840 retval = journal_end(&th, dir->i_sb, jbegin_count);
843 reiserfs_write_unlock_xattrs(dir->i_sb);
844 reiserfs_write_unlock(dir->i_sb);
848 static inline int reiserfs_empty_dir(struct inode *inode)
850 /* we can cheat because an old format dir cannot have
851 ** EMPTY_DIR_SIZE, and a new format dir cannot have
852 ** EMPTY_DIR_SIZE_V1. So, if the inode is either size,
853 ** regardless of disk format version, the directory is empty.
855 if (inode->i_size != EMPTY_DIR_SIZE &&
856 inode->i_size != EMPTY_DIR_SIZE_V1) {
862 static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry)
866 struct reiserfs_transaction_handle th;
868 INITIALIZE_PATH(path);
869 struct reiserfs_dir_entry de;
871 /* we will be doing 2 balancings and update 2 stat data, we change quotas
872 * of the owner of the directory and of the owner of the parent directory.
873 * The quota structure is possibly deleted only on last iput => outside
874 * of this transaction */
876 JOURNAL_PER_BALANCE_CNT * 2 + 2 +
877 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
879 reiserfs_write_lock(dir->i_sb);
880 retval = journal_begin(&th, dir->i_sb, jbegin_count);
884 de.de_gen_number_bit_string = NULL;
886 reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
887 &path, &de)) == NAME_NOT_FOUND) {
890 } else if (retval == IO_ERROR) {
895 inode = dentry->d_inode;
897 reiserfs_update_inode_transaction(inode);
898 reiserfs_update_inode_transaction(dir);
900 if (de.de_objectid != inode->i_ino) {
901 // FIXME: compare key of an object and a key found in the
906 if (!reiserfs_empty_dir(inode)) {
911 /* cut entry from dir directory */
912 retval = reiserfs_cut_from_item(&th, &path, &(de.de_entry_key), dir, NULL, /* page */
913 0 /*new file size - not used here */ );
917 if (inode->i_nlink != 2 && inode->i_nlink != 1)
918 reiserfs_warning(inode->i_sb, "%s: empty directory has nlink "
919 "!= 2 (%d)", __FUNCTION__, inode->i_nlink);
922 inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
923 reiserfs_update_sd(&th, inode);
925 DEC_DIR_INODE_NLINK(dir)
926 dir->i_size -= (DEH_SIZE + de.de_entrylen);
927 reiserfs_update_sd(&th, dir);
929 /* prevent empty directory from getting lost */
930 add_save_link(&th, inode, 0 /* not truncate */ );
932 retval = journal_end(&th, dir->i_sb, jbegin_count);
933 reiserfs_check_path(&path);
935 reiserfs_write_unlock(dir->i_sb);
939 /* we must release path, because we did not call
940 reiserfs_cut_from_item, or reiserfs_cut_from_item does not
941 release path if operation was not complete */
943 err = journal_end(&th, dir->i_sb, jbegin_count);
944 reiserfs_write_unlock(dir->i_sb);
945 return err ? err : retval;
948 static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
952 struct reiserfs_dir_entry de;
953 INITIALIZE_PATH(path);
954 struct reiserfs_transaction_handle th;
956 unsigned long savelink;
958 inode = dentry->d_inode;
960 /* in this transaction we can be doing at max two balancings and update
961 * two stat datas, we change quotas of the owner of the directory and of
962 * the owner of the parent directory. The quota structure is possibly
963 * deleted only on iput => outside of this transaction */
965 JOURNAL_PER_BALANCE_CNT * 2 + 2 +
966 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
968 reiserfs_write_lock(dir->i_sb);
969 retval = journal_begin(&th, dir->i_sb, jbegin_count);
973 de.de_gen_number_bit_string = NULL;
975 reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
976 &path, &de)) == NAME_NOT_FOUND) {
979 } else if (retval == IO_ERROR) {
984 reiserfs_update_inode_transaction(inode);
985 reiserfs_update_inode_transaction(dir);
987 if (de.de_objectid != inode->i_ino) {
988 // FIXME: compare key of an object and a key found in the
994 if (!inode->i_nlink) {
995 reiserfs_warning(inode->i_sb, "%s: deleting nonexistent file "
996 "(%s:%lu), %d", __FUNCTION__,
997 reiserfs_bdevname(inode->i_sb), inode->i_ino,
1005 * we schedule before doing the add_save_link call, save the link
1006 * count so we don't race
1008 savelink = inode->i_nlink;
1011 reiserfs_cut_from_item(&th, &path, &(de.de_entry_key), dir, NULL,
1017 inode->i_ctime = CURRENT_TIME_SEC;
1018 reiserfs_update_sd(&th, inode);
1020 dir->i_size -= (de.de_entrylen + DEH_SIZE);
1021 dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
1022 reiserfs_update_sd(&th, dir);
1025 /* prevent file from getting lost */
1026 add_save_link(&th, inode, 0 /* not truncate */ );
1028 retval = journal_end(&th, dir->i_sb, jbegin_count);
1029 reiserfs_check_path(&path);
1030 reiserfs_write_unlock(dir->i_sb);
1035 err = journal_end(&th, dir->i_sb, jbegin_count);
1036 reiserfs_check_path(&path);
1040 reiserfs_write_unlock(dir->i_sb);
1044 static int reiserfs_symlink(struct inode *parent_dir,
1045 struct dentry *dentry, const char *symname)
1048 struct inode *inode;
1051 struct reiserfs_transaction_handle th;
1052 int mode = S_IFLNK | S_IRWXUGO;
1053 /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
1055 JOURNAL_PER_BALANCE_CNT * 3 +
1056 2 * (REISERFS_QUOTA_INIT_BLOCKS(parent_dir->i_sb) +
1057 REISERFS_QUOTA_TRANS_BLOCKS(parent_dir->i_sb));
1059 if (!(inode = new_inode(parent_dir->i_sb))) {
1062 new_inode_init(inode, parent_dir, mode);
1064 reiserfs_write_lock(parent_dir->i_sb);
1065 item_len = ROUND_UP(strlen(symname));
1066 if (item_len > MAX_DIRECT_ITEM_LEN(parent_dir->i_sb->s_blocksize)) {
1067 retval = -ENAMETOOLONG;
1068 drop_new_inode(inode);
1072 name = reiserfs_kmalloc(item_len, GFP_NOFS, parent_dir->i_sb);
1074 drop_new_inode(inode);
1078 memcpy(name, symname, strlen(symname));
1079 padd_item(name, item_len, strlen(symname));
1081 /* We would inherit the default ACL here, but symlinks don't get ACLs */
1083 retval = journal_begin(&th, parent_dir->i_sb, jbegin_count);
1085 drop_new_inode(inode);
1086 reiserfs_kfree(name, item_len, parent_dir->i_sb);
1091 reiserfs_new_inode(&th, parent_dir, mode, name, strlen(symname),
1093 reiserfs_kfree(name, item_len, parent_dir->i_sb);
1094 if (retval) { /* reiserfs_new_inode iputs for us */
1098 reiserfs_update_inode_transaction(inode);
1099 reiserfs_update_inode_transaction(parent_dir);
1101 inode->i_op = &reiserfs_symlink_inode_operations;
1102 inode->i_mapping->a_ops = &reiserfs_address_space_operations;
1104 // must be sure this inode is written with this transaction
1106 //reiserfs_update_sd (&th, inode, READ_BLOCKS);
1108 retval = reiserfs_add_entry(&th, parent_dir, dentry->d_name.name,
1109 dentry->d_name.len, inode, 1 /*visible */ );
1113 reiserfs_update_sd(&th, inode);
1114 err = journal_end(&th, parent_dir->i_sb, jbegin_count);
1121 d_instantiate(dentry, inode);
1122 retval = journal_end(&th, parent_dir->i_sb, jbegin_count);
1124 reiserfs_write_unlock(parent_dir->i_sb);
1128 static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
1129 struct dentry *dentry)
1132 struct inode *inode = old_dentry->d_inode;
1133 struct reiserfs_transaction_handle th;
1134 /* We need blocks for transaction + update of quotas for the owners of the directory */
1136 JOURNAL_PER_BALANCE_CNT * 3 +
1137 2 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
1139 reiserfs_write_lock(dir->i_sb);
1140 if (inode->i_nlink >= REISERFS_LINK_MAX) {
1141 //FIXME: sd_nlink is 32 bit for new files
1142 reiserfs_write_unlock(dir->i_sb);
1145 if (inode->i_nlink == 0) {
1146 reiserfs_write_unlock(dir->i_sb);
1150 /* inc before scheduling so reiserfs_unlink knows we are here */
1153 retval = journal_begin(&th, dir->i_sb, jbegin_count);
1156 reiserfs_write_unlock(dir->i_sb);
1160 /* create new entry */
1162 reiserfs_add_entry(&th, dir, dentry->d_name.name,
1163 dentry->d_name.len, inode, 1 /*visible */ );
1165 reiserfs_update_inode_transaction(inode);
1166 reiserfs_update_inode_transaction(dir);
1171 err = journal_end(&th, dir->i_sb, jbegin_count);
1172 reiserfs_write_unlock(dir->i_sb);
1173 return err ? err : retval;
1176 inode->i_ctime = CURRENT_TIME_SEC;
1177 reiserfs_update_sd(&th, inode);
1179 atomic_inc(&inode->i_count);
1180 d_instantiate(dentry, inode);
1181 retval = journal_end(&th, dir->i_sb, jbegin_count);
1182 reiserfs_write_unlock(dir->i_sb);
1186 // de contains information pointing to an entry which
1187 static int de_still_valid(const char *name, int len,
1188 struct reiserfs_dir_entry *de)
1190 struct reiserfs_dir_entry tmp = *de;
1192 // recalculate pointer to name and name length
1193 set_de_name_and_namelen(&tmp);
1194 // FIXME: could check more
1195 if (tmp.de_namelen != len || memcmp(name, de->de_name, len))
1200 static int entry_points_to_object(const char *name, int len,
1201 struct reiserfs_dir_entry *de,
1202 struct inode *inode)
1204 if (!de_still_valid(name, len, de))
1208 if (!de_visible(de->de_deh + de->de_entry_num))
1209 reiserfs_panic(NULL,
1210 "vs-7042: entry_points_to_object: entry must be visible");
1211 return (de->de_objectid == inode->i_ino) ? 1 : 0;
1214 /* this must be added hidden entry */
1215 if (de_visible(de->de_deh + de->de_entry_num))
1216 reiserfs_panic(NULL,
1217 "vs-7043: entry_points_to_object: entry must be visible");
1222 /* sets key of objectid the entry has to point to */
1223 static void set_ino_in_dir_entry(struct reiserfs_dir_entry *de,
1224 struct reiserfs_key *key)
1226 /* JDM These operations are endian safe - both are le */
1227 de->de_deh[de->de_entry_num].deh_dir_id = key->k_dir_id;
1228 de->de_deh[de->de_entry_num].deh_objectid = key->k_objectid;
1232 * process, that is going to call fix_nodes/do_balance must hold only
1233 * one path. If it holds 2 or more, it can get into endless waiting in
1234 * get_empty_nodes or its clones
1236 static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1237 struct inode *new_dir, struct dentry *new_dentry)
1240 INITIALIZE_PATH(old_entry_path);
1241 INITIALIZE_PATH(new_entry_path);
1242 INITIALIZE_PATH(dot_dot_entry_path);
1243 struct item_head new_entry_ih, old_entry_ih, dot_dot_ih;
1244 struct reiserfs_dir_entry old_de, new_de, dot_dot_de;
1245 struct inode *old_inode, *new_dentry_inode;
1246 struct reiserfs_transaction_handle th;
1248 umode_t old_inode_mode;
1249 unsigned long savelink = 1;
1250 struct timespec ctime;
1252 /* three balancings: (1) old name removal, (2) new name insertion
1253 and (3) maybe "save" link insertion
1254 stat data updates: (1) old directory,
1255 (2) new directory and (3) maybe old object stat data (when it is
1256 directory) and (4) maybe stat data of object to which new entry
1257 pointed initially and (5) maybe block containing ".." of
1259 quota updates: two parent directories */
1261 JOURNAL_PER_BALANCE_CNT * 3 + 5 +
1262 4 * REISERFS_QUOTA_TRANS_BLOCKS(old_dir->i_sb);
1264 old_inode = old_dentry->d_inode;
1265 new_dentry_inode = new_dentry->d_inode;
1267 // make sure, that oldname still exists and points to an object we
1268 // are going to rename
1269 old_de.de_gen_number_bit_string = NULL;
1270 reiserfs_write_lock(old_dir->i_sb);
1272 reiserfs_find_entry(old_dir, old_dentry->d_name.name,
1273 old_dentry->d_name.len, &old_entry_path,
1275 pathrelse(&old_entry_path);
1276 if (retval == IO_ERROR) {
1277 reiserfs_write_unlock(old_dir->i_sb);
1281 if (retval != NAME_FOUND || old_de.de_objectid != old_inode->i_ino) {
1282 reiserfs_write_unlock(old_dir->i_sb);
1286 old_inode_mode = old_inode->i_mode;
1287 if (S_ISDIR(old_inode_mode)) {
1288 // make sure, that directory being renamed has correct ".."
1289 // and that its new parent directory has not too many links
1292 if (new_dentry_inode) {
1293 if (!reiserfs_empty_dir(new_dentry_inode)) {
1294 reiserfs_write_unlock(old_dir->i_sb);
1299 /* directory is renamed, its parent directory will be changed,
1300 ** so find ".." entry
1302 dot_dot_de.de_gen_number_bit_string = NULL;
1304 reiserfs_find_entry(old_inode, "..", 2, &dot_dot_entry_path,
1306 pathrelse(&dot_dot_entry_path);
1307 if (retval != NAME_FOUND) {
1308 reiserfs_write_unlock(old_dir->i_sb);
1312 /* inode number of .. must equal old_dir->i_ino */
1313 if (dot_dot_de.de_objectid != old_dir->i_ino) {
1314 reiserfs_write_unlock(old_dir->i_sb);
1319 retval = journal_begin(&th, old_dir->i_sb, jbegin_count);
1321 reiserfs_write_unlock(old_dir->i_sb);
1325 /* add new entry (or find the existing one) */
1327 reiserfs_add_entry(&th, new_dir, new_dentry->d_name.name,
1328 new_dentry->d_name.len, old_inode, 0);
1329 if (retval == -EEXIST) {
1330 if (!new_dentry_inode) {
1331 reiserfs_panic(old_dir->i_sb,
1332 "vs-7050: new entry is found, new inode == 0\n");
1334 } else if (retval) {
1335 int err = journal_end(&th, old_dir->i_sb, jbegin_count);
1336 reiserfs_write_unlock(old_dir->i_sb);
1337 return err ? err : retval;
1340 reiserfs_update_inode_transaction(old_dir);
1341 reiserfs_update_inode_transaction(new_dir);
1343 /* this makes it so an fsync on an open fd for the old name will
1344 ** commit the rename operation
1346 reiserfs_update_inode_transaction(old_inode);
1348 if (new_dentry_inode)
1349 reiserfs_update_inode_transaction(new_dentry_inode);
1352 // look for old name using corresponding entry key (found by reiserfs_find_entry)
1354 search_by_entry_key(new_dir->i_sb, &old_de.de_entry_key,
1356 &old_de)) != NAME_FOUND) {
1357 pathrelse(&old_entry_path);
1358 journal_end(&th, old_dir->i_sb, jbegin_count);
1359 reiserfs_write_unlock(old_dir->i_sb);
1363 copy_item_head(&old_entry_ih, get_ih(&old_entry_path));
1365 reiserfs_prepare_for_journal(old_inode->i_sb, old_de.de_bh, 1);
1367 // look for new name by reiserfs_find_entry
1368 new_de.de_gen_number_bit_string = NULL;
1370 reiserfs_find_entry(new_dir, new_dentry->d_name.name,
1371 new_dentry->d_name.len, &new_entry_path,
1373 // reiserfs_add_entry should not return IO_ERROR, because it is called with essentially same parameters from
1374 // reiserfs_add_entry above, and we'll catch any i/o errors before we get here.
1375 if (retval != NAME_FOUND_INVISIBLE && retval != NAME_FOUND) {
1376 pathrelse(&new_entry_path);
1377 pathrelse(&old_entry_path);
1378 journal_end(&th, old_dir->i_sb, jbegin_count);
1379 reiserfs_write_unlock(old_dir->i_sb);
1383 copy_item_head(&new_entry_ih, get_ih(&new_entry_path));
1385 reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1);
1387 if (S_ISDIR(old_inode->i_mode)) {
1389 search_by_entry_key(new_dir->i_sb,
1390 &dot_dot_de.de_entry_key,
1391 &dot_dot_entry_path,
1392 &dot_dot_de)) != NAME_FOUND) {
1393 pathrelse(&dot_dot_entry_path);
1394 pathrelse(&new_entry_path);
1395 pathrelse(&old_entry_path);
1396 journal_end(&th, old_dir->i_sb, jbegin_count);
1397 reiserfs_write_unlock(old_dir->i_sb);
1400 copy_item_head(&dot_dot_ih,
1401 get_ih(&dot_dot_entry_path));
1402 // node containing ".." gets into transaction
1403 reiserfs_prepare_for_journal(old_inode->i_sb,
1404 dot_dot_de.de_bh, 1);
1406 /* we should check seals here, not do
1407 this stuff, yes? Then, having
1408 gathered everything into RAM we
1409 should lock the buffers, yes? -Hans */
1410 /* probably. our rename needs to hold more
1411 ** than one path at once. The seals would
1412 ** have to be written to deal with multi-path
1415 /* sanity checking before doing the rename - avoid races many
1416 ** of the above checks could have scheduled. We have to be
1417 ** sure our items haven't been shifted by another process.
1419 if (item_moved(&new_entry_ih, &new_entry_path) ||
1420 !entry_points_to_object(new_dentry->d_name.name,
1421 new_dentry->d_name.len,
1422 &new_de, new_dentry_inode) ||
1423 item_moved(&old_entry_ih, &old_entry_path) ||
1424 !entry_points_to_object(old_dentry->d_name.name,
1425 old_dentry->d_name.len,
1426 &old_de, old_inode)) {
1427 reiserfs_restore_prepared_buffer(old_inode->i_sb,
1429 reiserfs_restore_prepared_buffer(old_inode->i_sb,
1431 if (S_ISDIR(old_inode_mode))
1432 reiserfs_restore_prepared_buffer(old_inode->
1438 if (S_ISDIR(old_inode_mode)) {
1439 if (item_moved(&dot_dot_ih, &dot_dot_entry_path) ||
1440 !entry_points_to_object("..", 2, &dot_dot_de,
1442 reiserfs_restore_prepared_buffer(old_inode->
1445 reiserfs_restore_prepared_buffer(old_inode->
1448 reiserfs_restore_prepared_buffer(old_inode->
1456 RFALSE(S_ISDIR(old_inode_mode) &&
1457 !buffer_journal_prepared(dot_dot_de.de_bh), "");
1462 /* ok, all the changes can be done in one fell swoop when we
1463 have claimed all the buffers needed. */
1465 mark_de_visible(new_de.de_deh + new_de.de_entry_num);
1466 set_ino_in_dir_entry(&new_de, INODE_PKEY(old_inode));
1467 journal_mark_dirty(&th, old_dir->i_sb, new_de.de_bh);
1469 mark_de_hidden(old_de.de_deh + old_de.de_entry_num);
1470 journal_mark_dirty(&th, old_dir->i_sb, old_de.de_bh);
1471 ctime = CURRENT_TIME_SEC;
1472 old_dir->i_ctime = old_dir->i_mtime = ctime;
1473 new_dir->i_ctime = new_dir->i_mtime = ctime;
1474 /* thanks to Alex Adriaanse <alex_a@caltech.edu> for patch which adds ctime update of
1476 old_inode->i_ctime = ctime;
1478 if (new_dentry_inode) {
1479 // adjust link number of the victim
1480 if (S_ISDIR(new_dentry_inode->i_mode)) {
1481 new_dentry_inode->i_nlink = 0;
1483 new_dentry_inode->i_nlink--;
1485 new_dentry_inode->i_ctime = ctime;
1486 savelink = new_dentry_inode->i_nlink;
1489 if (S_ISDIR(old_inode_mode)) {
1490 // adjust ".." of renamed directory
1491 set_ino_in_dir_entry(&dot_dot_de, INODE_PKEY(new_dir));
1492 journal_mark_dirty(&th, new_dir->i_sb, dot_dot_de.de_bh);
1494 if (!new_dentry_inode)
1495 /* there (in new_dir) was no directory, so it got new link
1496 (".." of renamed directory) */
1497 INC_DIR_INODE_NLINK(new_dir);
1499 /* old directory lost one link - ".. " of renamed directory */
1500 DEC_DIR_INODE_NLINK(old_dir);
1502 // looks like in 2.3.99pre3 brelse is atomic. so we can use pathrelse
1503 pathrelse(&new_entry_path);
1504 pathrelse(&dot_dot_entry_path);
1506 // FIXME: this reiserfs_cut_from_item's return value may screw up
1507 // anybody, but it will panic if will not be able to find the
1508 // entry. This needs one more clean up
1509 if (reiserfs_cut_from_item
1510 (&th, &old_entry_path, &(old_de.de_entry_key), old_dir, NULL,
1512 reiserfs_warning(old_dir->i_sb,
1513 "vs-7060: reiserfs_rename: couldn't not cut old name. Fsck later?");
1515 old_dir->i_size -= DEH_SIZE + old_de.de_entrylen;
1517 reiserfs_update_sd(&th, old_dir);
1518 reiserfs_update_sd(&th, new_dir);
1519 reiserfs_update_sd(&th, old_inode);
1521 if (new_dentry_inode) {
1523 add_save_link(&th, new_dentry_inode,
1524 0 /* not truncate */ );
1525 reiserfs_update_sd(&th, new_dentry_inode);
1528 retval = journal_end(&th, old_dir->i_sb, jbegin_count);
1529 reiserfs_write_unlock(old_dir->i_sb);
1534 * directories can handle most operations...
1536 struct inode_operations reiserfs_dir_inode_operations = {
1537 //&reiserfs_dir_operations, /* default_file_ops */
1538 .create = reiserfs_create,
1539 .lookup = reiserfs_lookup,
1540 .link = reiserfs_link,
1541 .unlink = reiserfs_unlink,
1542 .symlink = reiserfs_symlink,
1543 .mkdir = reiserfs_mkdir,
1544 .rmdir = reiserfs_rmdir,
1545 .mknod = reiserfs_mknod,
1546 .rename = reiserfs_rename,
1547 .setattr = reiserfs_setattr,
1548 .setxattr = reiserfs_setxattr,
1549 .getxattr = reiserfs_getxattr,
1550 .listxattr = reiserfs_listxattr,
1551 .removexattr = reiserfs_removexattr,
1552 .permission = reiserfs_permission,
1556 * symlink operations.. same as page_symlink_inode_operations, with xattr
1559 struct inode_operations reiserfs_symlink_inode_operations = {
1560 .readlink = generic_readlink,
1561 .follow_link = page_follow_link_light,
1562 .put_link = page_put_link,
1563 .setattr = reiserfs_setattr,
1564 .setxattr = reiserfs_setxattr,
1565 .getxattr = reiserfs_getxattr,
1566 .listxattr = reiserfs_listxattr,
1567 .removexattr = reiserfs_removexattr,
1568 .permission = reiserfs_permission,
1573 * special file operations.. just xattr/acl stuff
1575 struct inode_operations reiserfs_special_inode_operations = {
1576 .setattr = reiserfs_setattr,
1577 .setxattr = reiserfs_setxattr,
1578 .getxattr = reiserfs_getxattr,
1579 .listxattr = reiserfs_listxattr,
1580 .removexattr = reiserfs_removexattr,
1581 .permission = reiserfs_permission,