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; j = (rbound + lbound) / 2) {
38 if (off < deh_offset (deh + j)) {
42 if (off > deh_offset (deh + j)) {
46 // this is not name found, but matched third key component
51 de->de_entry_num = lbound;
52 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, struct path * path)
59 de->de_bh = get_last_bh (path);
60 de->de_ih = get_ih (path);
61 de->de_deh = B_I_DEH (de->de_bh, de->de_ih);
62 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);
82 // what entry points to
83 static inline void set_de_object_key (struct reiserfs_dir_entry * de)
85 if (de->de_entry_num >= ih_entry_count (de->de_ih))
87 de->de_dir_id = deh_dir_id( &(de->de_deh[de->de_entry_num]));
88 de->de_objectid = deh_objectid( &(de->de_deh[de->de_entry_num]));
92 static inline void store_de_entry_key (struct reiserfs_dir_entry * de)
94 struct reiserfs_de_head * deh = de->de_deh + de->de_entry_num;
96 if (de->de_entry_num >= ih_entry_count (de->de_ih))
99 /* store key of the found entry */
100 de->de_entry_key.version = KEY_FORMAT_3_5;
101 de->de_entry_key.on_disk_key.k_dir_id = le32_to_cpu (de->de_ih->ih_key.k_dir_id);
102 de->de_entry_key.on_disk_key.k_objectid = 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);
108 /* We assign a key to each directory item, and place multiple entries
109 in a single directory item. A directory item has a key equal to the
110 key of the first directory entry in it.
112 This function first calls search_by_key, then, if item whose first
113 entry matches is not found it looks for the entry inside directory
114 item found by search_by_key. Fills the path to the entry, and to the
115 entry position in the item
119 /* The function is NOT SCHEDULE-SAFE! */
120 int search_by_entry_key (struct super_block * sb, const struct cpu_key * key,
121 struct path * path, struct reiserfs_dir_entry * de)
125 retval = search_item (sb, key, path);
128 if (!PATH_LAST_POSITION (path)) {
129 reiserfs_warning (sb, "vs-7000: search_by_entry_key: search_by_key returned item position == 0");
133 PATH_LAST_POSITION (path) --;
143 reiserfs_warning (sb, "vs-7002: search_by_entry_key: no path to here");
147 set_de_item_location (de, path);
149 #ifdef CONFIG_REISERFS_CHECK
150 if (!is_direntry_le_ih (de->de_ih) ||
151 COMP_SHORT_KEYS (&(de->de_ih->ih_key), key)) {
152 print_block (de->de_bh, 0, -1, -1);
153 reiserfs_panic (sb, "vs-7005: search_by_entry_key: found item %h is not directory item or "
154 "does not belong to the same directory as key %K", de->de_ih, key);
156 #endif /* CONFIG_REISERFS_CHECK */
158 /* binary search in directory item by third componen t of the
159 key. sets de->de_entry_num of de */
160 retval = bin_search_in_dir_item (de, cpu_key_k_offset (key));
161 path->pos_in_item = de->de_entry_num;
162 if (retval != NAME_NOT_FOUND) {
163 // ugly, but rename needs de_bh, de_deh, de_name, de_namelen, de_objectid set
164 set_de_name_and_namelen (de);
165 set_de_object_key (de);
172 /* Keyed 32-bit hash function using TEA in a Davis-Meyer function */
174 /* The third component is hashed, and you can choose from more than
175 one hash function. Per directory hashes are not yet implemented
176 but are thought about. This function should be moved to hashes.c
177 Jedi, please do so. -Hans */
179 static __u32 get_third_component (struct super_block * s,
180 const char * name, int len)
184 if (!len || (len == 1 && name[0] == '.'))
186 if (len == 2 && name[0] == '.' && name[1] == '.')
187 return DOT_DOT_OFFSET;
189 res = REISERFS_SB(s)->s_hash_function (name, len);
191 // take bits from 7-th to 30-th including both bounds
192 res = GET_HASH_VALUE(res);
194 // needed to have no names before "." and ".." those have hash
195 // value == 0 and generation conters 1 and 2 accordingly
197 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))
208 retval = (de_visible (de->de_deh + de->de_entry_num) ? NAME_FOUND : NAME_FOUND_INVISIBLE);
214 /* de's de_bh, de_ih, de_deh, de_item_num, de_entry_num are set already */
216 /* used when hash collisions exist */
219 static int linear_search_in_dir_item (struct cpu_key * key, struct reiserfs_dir_entry * de,
220 const char * name, int namelen)
222 struct reiserfs_de_head * deh = de->de_deh;
226 i = de->de_entry_num;
228 if (i == I_ENTRY_COUNT (de->de_ih) ||
229 GET_HASH_VALUE (deh_offset (deh + i)) != GET_HASH_VALUE (cpu_key_k_offset (key))) {
233 RFALSE( de->de_deh != B_I_DEH (de->de_bh, de->de_ih),
234 "vs-7010: array of entry headers not found");
238 for (; i >= 0; i --, deh --) {
239 if (GET_HASH_VALUE (deh_offset (deh)) !=
240 GET_HASH_VALUE (cpu_key_k_offset (key))) {
241 // hash value does not match, no need to check whole name
242 return NAME_NOT_FOUND;
245 /* mark, that this generation number is used */
246 if (de->de_gen_number_bit_string)
247 set_bit (GET_GENERATION_NUMBER (deh_offset (deh)), (unsigned long *)de->de_gen_number_bit_string);
249 // calculate pointer to name and namelen
250 de->de_entry_num = i;
251 set_de_name_and_namelen (de);
253 if ((retval = reiserfs_match (de, name, namelen)) != NAME_NOT_FOUND) {
254 // de's de_name, de_namelen, de_recordlen are set. Fill the rest:
256 // key of pointed object
257 set_de_object_key (de);
259 store_de_entry_key (de);
261 // retval can be NAME_FOUND or NAME_FOUND_INVISIBLE
266 if (GET_GENERATION_NUMBER (le_ih_k_offset (de->de_ih)) == 0)
267 /* we have reached left most entry in the node. In common we
268 have to go to the left neighbor, but if generation counter
269 is 0 already, we know for sure, that there is no name with
270 the same hash value */
271 // FIXME: this work correctly only because hash value can not
272 // be 0. Btw, in case of Yura's hash it is probably possible,
274 return NAME_NOT_FOUND;
276 RFALSE( de->de_item_num,
277 "vs-7015: two diritems of the same directory in one node?");
279 return GOTO_PREVIOUS_ITEM;
283 // may return NAME_FOUND, NAME_FOUND_INVISIBLE, NAME_NOT_FOUND
284 // FIXME: should add something like IOERROR
285 static int reiserfs_find_entry (struct inode * dir, const char * name, int namelen,
286 struct path * path_to_entry, struct reiserfs_dir_entry * de)
288 struct cpu_key key_to_search;
292 if (namelen > REISERFS_MAX_NAME (dir->i_sb->s_blocksize))
293 return NAME_NOT_FOUND;
295 /* we will search for this key in the tree */
296 make_cpu_key (&key_to_search, dir,
297 get_third_component (dir->i_sb, name, namelen), TYPE_DIRENTRY, 3);
300 retval = search_by_entry_key (dir->i_sb, &key_to_search, path_to_entry, de);
301 if (retval == IO_ERROR) {
302 reiserfs_warning (dir->i_sb, "zam-7001: io error in %s",
307 /* compare names for all entries having given hash value */
308 retval = linear_search_in_dir_item (&key_to_search, de, name, namelen);
309 if (retval != GOTO_PREVIOUS_ITEM) {
310 /* there is no need to scan directory anymore. Given entry found or does not exist */
311 path_to_entry->pos_in_item = de->de_entry_num;
315 /* there is left neighboring item of this directory and given entry can be there */
316 set_cpu_key_k_offset (&key_to_search, le_ih_k_offset (de->de_ih) - 1);
317 pathrelse (path_to_entry);
323 static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dentry, struct nameidata *nd)
326 struct inode * inode = NULL;
327 struct reiserfs_dir_entry de;
328 INITIALIZE_PATH (path_to_entry);
330 if (REISERFS_MAX_NAME (dir->i_sb->s_blocksize) < dentry->d_name.len)
331 return ERR_PTR(-ENAMETOOLONG);
333 reiserfs_write_lock(dir->i_sb);
334 de.de_gen_number_bit_string = NULL;
335 retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path_to_entry, &de);
336 pathrelse (&path_to_entry);
337 if (retval == NAME_FOUND) {
338 /* Hide the .reiserfs_priv directory */
339 if (reiserfs_xattrs (dir->i_sb) &&
340 !old_format_only(dir->i_sb) &&
341 REISERFS_SB(dir->i_sb)->priv_root &&
342 REISERFS_SB(dir->i_sb)->priv_root->d_inode &&
343 de.de_objectid == le32_to_cpu (INODE_PKEY(REISERFS_SB(dir->i_sb)->priv_root->d_inode)->k_objectid)) {
344 reiserfs_write_unlock (dir->i_sb);
345 return ERR_PTR (-EACCES);
348 inode = reiserfs_iget (dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
349 if (!inode || IS_ERR(inode)) {
350 reiserfs_write_unlock(dir->i_sb);
351 return ERR_PTR(-EACCES);
354 /* Propogate the priv_object flag so we know we're in the priv tree */
355 if (is_reiserfs_priv_object (dir))
356 reiserfs_mark_inode_private (inode);
358 reiserfs_write_unlock(dir->i_sb);
359 if ( retval == IO_ERROR ) {
360 return ERR_PTR(-EIO);
364 return d_splice_alias(inode, dentry);
366 d_add(dentry, inode);
372 ** looks up the dentry of the parent directory for child.
373 ** taken from ext2_get_parent
375 struct dentry *reiserfs_get_parent(struct dentry *child)
378 struct inode * inode = NULL;
379 struct reiserfs_dir_entry de;
380 INITIALIZE_PATH (path_to_entry);
381 struct dentry *parent;
382 struct inode *dir = child->d_inode ;
385 if (dir->i_nlink == 0) {
386 return ERR_PTR(-ENOENT);
388 de.de_gen_number_bit_string = NULL;
390 reiserfs_write_lock(dir->i_sb);
391 retval = reiserfs_find_entry (dir, "..", 2, &path_to_entry, &de);
392 pathrelse (&path_to_entry);
393 if (retval != NAME_FOUND) {
394 reiserfs_write_unlock(dir->i_sb);
395 return ERR_PTR(-ENOENT);
397 inode = reiserfs_iget (dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
398 reiserfs_write_unlock(dir->i_sb);
400 if (!inode || IS_ERR(inode)) {
401 return ERR_PTR(-EACCES);
403 parent = d_alloc_anon(inode);
406 parent = ERR_PTR(-ENOMEM);
412 /* add entry to the directory (entry can be hidden).
414 insert definition of when hidden directories are used here -Hans
416 Does not mark dir inode dirty, do it after successesfull call to it */
418 static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct inode * dir,
419 const char * name, int namelen, struct inode * inode,
422 struct cpu_key entry_key;
423 struct reiserfs_de_head * deh;
424 INITIALIZE_PATH (path);
425 struct reiserfs_dir_entry de;
426 int bit_string [MAX_GENERATION_NUMBER / (sizeof(int) * 8) + 1];
428 char small_buf[32+DEH_SIZE] ; /* 48 bytes now and we avoid kmalloc
429 if we create file with short name */
431 int buflen, paste_size;
434 BUG_ON (!th->t_trans_id);
436 /* cannot allow items to be added into a busy deleted directory */
440 if (namelen > REISERFS_MAX_NAME (dir->i_sb->s_blocksize))
441 return -ENAMETOOLONG;
443 /* each entry has unique key. compose it */
444 make_cpu_key (&entry_key, dir,
445 get_third_component (dir->i_sb, name, namelen), TYPE_DIRENTRY, 3);
447 /* get memory for composing the entry */
448 buflen = DEH_SIZE + ROUND_UP (namelen);
449 if (buflen > sizeof (small_buf)) {
450 buffer = reiserfs_kmalloc (buflen, GFP_NOFS, dir->i_sb);
456 paste_size = (get_inode_sd_version (dir) == STAT_DATA_V1) ? (DEH_SIZE + namelen) : buflen;
458 /* fill buffer : directory entry head, name[, dir objectid | , stat data | ,stat data, dir objectid ] */
459 deh = (struct reiserfs_de_head *)buffer;
460 deh->deh_location = 0; /* JDM Endian safe if 0 */
461 put_deh_offset( deh, cpu_key_k_offset( &entry_key ) );
462 deh->deh_state = 0; /* JDM Endian safe if 0 */
463 /* put key (ino analog) to de */
464 deh->deh_dir_id = INODE_PKEY (inode)->k_dir_id; /* safe: k_dir_id is le */
465 deh->deh_objectid = INODE_PKEY (inode)->k_objectid; /* safe: k_objectid is le */
468 memcpy ((char *)(deh + 1), name, namelen);
469 /* padd by 0s to the 4 byte boundary */
470 padd_item ((char *)(deh + 1), ROUND_UP (namelen), namelen);
472 /* entry is ready to be pasted into tree, set 'visibility' and 'stat data in entry' attributes */
473 mark_de_without_sd (deh);
474 visible ? mark_de_visible (deh) : mark_de_hidden (deh);
476 /* find the proper place for the new entry */
477 memset (bit_string, 0, sizeof (bit_string));
478 de.de_gen_number_bit_string = (char *)bit_string;
479 retval = reiserfs_find_entry (dir, name, namelen, &path, &de);
480 if( retval != NAME_NOT_FOUND ) {
481 if (buffer != small_buf)
482 reiserfs_kfree (buffer, buflen, dir->i_sb);
485 if ( retval == IO_ERROR ) {
489 if (retval != NAME_FOUND) {
490 reiserfs_warning (dir->i_sb, "zam-7002:%s: \"reiserfs_find_entry\" "
491 "has returned unexpected value (%d)",
492 __FUNCTION__, retval);
498 gen_number = find_first_zero_bit ((unsigned long *)bit_string, MAX_GENERATION_NUMBER + 1);
499 if (gen_number > MAX_GENERATION_NUMBER) {
500 /* there is no free generation number */
501 reiserfs_warning (dir->i_sb, "reiserfs_add_entry: Congratulations! we have got hash function screwed up");
502 if (buffer != small_buf)
503 reiserfs_kfree (buffer, buflen, dir->i_sb);
507 /* adjust offset of directory enrty */
508 put_deh_offset(deh, SET_GENERATION_NUMBER(deh_offset(deh), gen_number));
509 set_cpu_key_k_offset (&entry_key, deh_offset(deh));
511 /* update max-hash-collisions counter in reiserfs_sb_info */
512 PROC_INFO_MAX( th -> t_super, max_hash_collisions, gen_number );
514 if (gen_number != 0) { /* we need to re-search for the insertion point */
515 if (search_by_entry_key (dir->i_sb, &entry_key, &path, &de) != NAME_NOT_FOUND) {
516 reiserfs_warning (dir->i_sb, "vs-7032: reiserfs_add_entry: "
517 "entry with this key (%K) already exists",
520 if (buffer != small_buf)
521 reiserfs_kfree (buffer, buflen, dir->i_sb);
527 /* perform the insertion of the entry that we have prepared */
528 retval = reiserfs_paste_into_item (th, &path, &entry_key, dir, buffer, paste_size);
529 if (buffer != small_buf)
530 reiserfs_kfree (buffer, buflen, dir->i_sb);
532 reiserfs_check_path(&path) ;
536 dir->i_size += paste_size;
537 dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
538 if (!S_ISDIR (inode->i_mode) && visible)
539 // reiserfs_mkdir or reiserfs_rename will do that by itself
540 reiserfs_update_sd (th, dir);
542 reiserfs_check_path(&path) ;
546 /* quota utility function, call if you've had to abort after calling
547 ** new_inode_init, and have not called reiserfs_new_inode yet.
548 ** This should only be called on inodes that do not have stat data
549 ** inserted into the tree yet.
551 static int drop_new_inode(struct inode *inode) {
553 make_bad_inode(inode) ;
554 inode->i_flags |= S_NOQUOTA;
559 /* utility function that does setup for reiserfs_new_inode.
560 ** DQUOT_INIT needs lots of credits so it's better to have it
561 ** outside of a transaction, so we had to pull some bits of
562 ** reiserfs_new_inode out into this func.
564 static int new_inode_init(struct inode *inode, struct inode *dir, int mode) {
566 /* the quota init calls have to know who to charge the quota to, so
567 ** we have to set uid and gid here
569 inode->i_uid = current->fsuid;
570 inode->i_mode = mode;
572 if (dir->i_mode & S_ISGID) {
573 inode->i_gid = dir->i_gid;
575 inode->i_mode |= S_ISGID;
577 inode->i_gid = current->fsgid;
583 static int reiserfs_create (struct inode * dir, struct dentry *dentry, int mode,
584 struct nameidata *nd)
587 struct inode * inode;
588 /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
589 int jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 * (REISERFS_QUOTA_INIT_BLOCKS+REISERFS_QUOTA_TRANS_BLOCKS);
590 struct reiserfs_transaction_handle th ;
593 if (!(inode = new_inode(dir->i_sb))) {
596 new_inode_init(inode, dir, mode);
598 locked = reiserfs_cache_default_acl (dir);
600 reiserfs_write_lock(dir->i_sb);
603 reiserfs_write_lock_xattrs (dir->i_sb);
605 retval = journal_begin(&th, dir->i_sb, jbegin_count);
607 drop_new_inode (inode);
611 retval = reiserfs_new_inode (&th, dir, mode, NULL, 0/*i_size*/, dentry, inode);
616 reiserfs_write_unlock_xattrs (dir->i_sb);
620 inode->i_op = &reiserfs_file_inode_operations;
621 inode->i_fop = &reiserfs_file_operations;
622 inode->i_mapping->a_ops = &reiserfs_address_space_operations ;
624 retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
625 inode, 1/*visible*/);
629 reiserfs_update_sd (&th, inode);
630 err = journal_end(&th, dir->i_sb, jbegin_count) ;
636 reiserfs_update_inode_transaction(inode) ;
637 reiserfs_update_inode_transaction(dir) ;
639 d_instantiate(dentry, inode);
640 retval = journal_end(&th, dir->i_sb, jbegin_count) ;
644 reiserfs_write_unlock_xattrs (dir->i_sb);
645 reiserfs_write_unlock(dir->i_sb);
650 static int reiserfs_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev)
653 struct inode * inode;
654 struct reiserfs_transaction_handle th ;
655 /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
656 int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * (REISERFS_QUOTA_INIT_BLOCKS+REISERFS_QUOTA_TRANS_BLOCKS);
659 if (!new_valid_dev(rdev))
662 if (!(inode = new_inode(dir->i_sb))) {
665 new_inode_init(inode, dir, mode);
667 locked = reiserfs_cache_default_acl (dir);
669 reiserfs_write_lock(dir->i_sb);
672 reiserfs_write_lock_xattrs (dir->i_sb);
674 retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
676 drop_new_inode (inode);
680 retval = reiserfs_new_inode (&th, dir, mode, NULL, 0/*i_size*/, dentry, inode);
686 reiserfs_write_unlock_xattrs (dir->i_sb);
691 inode->i_op = &reiserfs_special_inode_operations;
692 init_special_inode(inode, inode->i_mode, rdev) ;
694 //FIXME: needed for block and char devices only
695 reiserfs_update_sd (&th, inode);
697 reiserfs_update_inode_transaction(inode) ;
698 reiserfs_update_inode_transaction(dir) ;
700 retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
701 inode, 1/*visible*/);
705 reiserfs_update_sd (&th, inode);
706 err = journal_end(&th, dir->i_sb, jbegin_count) ;
713 d_instantiate(dentry, inode);
714 retval = journal_end(&th, dir->i_sb, jbegin_count) ;
718 reiserfs_write_unlock_xattrs (dir->i_sb);
719 reiserfs_write_unlock(dir->i_sb);
724 static int reiserfs_mkdir (struct inode * dir, struct dentry *dentry, int mode)
727 struct inode * inode;
728 struct reiserfs_transaction_handle th ;
729 /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
730 int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * (REISERFS_QUOTA_INIT_BLOCKS+REISERFS_QUOTA_TRANS_BLOCKS);
733 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
734 /* set flag that new packing locality created and new blocks for the content * of that directory are not displaced yet */
735 REISERFS_I(dir)->new_packing_locality = 1;
737 mode = S_IFDIR | mode;
738 if (!(inode = new_inode(dir->i_sb))) {
741 new_inode_init(inode, dir, mode);
743 locked = reiserfs_cache_default_acl (dir);
745 reiserfs_write_lock(dir->i_sb);
747 reiserfs_write_lock_xattrs (dir->i_sb);
749 retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
751 drop_new_inode (inode);
756 /* inc the link count now, so another writer doesn't overflow it while
757 ** we sleep later on.
759 INC_DIR_INODE_NLINK(dir)
761 retval = reiserfs_new_inode (&th, dir, mode, NULL/*symlink*/,
762 old_format_only (dir->i_sb) ?
763 EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
771 reiserfs_write_unlock_xattrs (dir->i_sb);
775 reiserfs_update_inode_transaction(inode) ;
776 reiserfs_update_inode_transaction(dir) ;
778 inode->i_op = &reiserfs_dir_inode_operations;
779 inode->i_fop = &reiserfs_dir_operations;
781 // note, _this_ add_entry will not update dir's stat data
782 retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
783 inode, 1/*visible*/);
787 DEC_DIR_INODE_NLINK(dir);
788 reiserfs_update_sd (&th, inode);
789 err = journal_end(&th, dir->i_sb, jbegin_count) ;
796 // the above add_entry did not update dir's stat data
797 reiserfs_update_sd (&th, dir);
799 d_instantiate(dentry, inode);
800 retval = journal_end(&th, dir->i_sb, jbegin_count) ;
803 reiserfs_write_unlock_xattrs (dir->i_sb);
804 reiserfs_write_unlock(dir->i_sb);
808 static inline int reiserfs_empty_dir(struct inode *inode) {
809 /* we can cheat because an old format dir cannot have
810 ** EMPTY_DIR_SIZE, and a new format dir cannot have
811 ** EMPTY_DIR_SIZE_V1. So, if the inode is either size,
812 ** regardless of disk format version, the directory is empty.
814 if (inode->i_size != EMPTY_DIR_SIZE &&
815 inode->i_size != EMPTY_DIR_SIZE_V1) {
821 static int reiserfs_rmdir (struct inode * dir, struct dentry *dentry)
824 struct inode * inode;
825 struct reiserfs_transaction_handle th ;
827 INITIALIZE_PATH (path);
828 struct reiserfs_dir_entry de;
831 /* we will be doing 2 balancings and update 2 stat data, we change quotas
832 * of the owner of the directory and of the owner of the parent directory */
833 jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 + 2 * (REISERFS_QUOTA_INIT_BLOCKS+REISERFS_QUOTA_TRANS_BLOCKS);
835 reiserfs_write_lock(dir->i_sb);
836 retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
840 de.de_gen_number_bit_string = NULL;
841 if ( (retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de)) == NAME_NOT_FOUND) {
844 } else if ( retval == IO_ERROR) {
849 inode = dentry->d_inode;
851 reiserfs_update_inode_transaction(inode) ;
852 reiserfs_update_inode_transaction(dir) ;
854 if (de.de_objectid != inode->i_ino) {
855 // FIXME: compare key of an object and a key found in the
860 if (!reiserfs_empty_dir(inode)) {
865 /* cut entry from dir directory */
866 retval = reiserfs_cut_from_item (&th, &path, &(de.de_entry_key), dir,
868 0/*new file size - not used here*/);
872 if ( inode->i_nlink != 2 && inode->i_nlink != 1 )
873 reiserfs_warning (inode->i_sb, "%s: empty directory has nlink "
874 "!= 2 (%d)", __FUNCTION__, inode->i_nlink);
877 inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
878 reiserfs_update_sd (&th, inode);
880 DEC_DIR_INODE_NLINK(dir)
881 dir->i_size -= (DEH_SIZE + de.de_entrylen);
882 reiserfs_update_sd (&th, dir);
884 /* prevent empty directory from getting lost */
885 add_save_link (&th, inode, 0/* not truncate */);
887 retval = journal_end(&th, dir->i_sb, jbegin_count) ;
888 reiserfs_check_path(&path) ;
890 reiserfs_write_unlock(dir->i_sb);
894 /* we must release path, because we did not call
895 reiserfs_cut_from_item, or reiserfs_cut_from_item does not
896 release path if operation was not complete */
898 err = journal_end(&th, dir->i_sb, jbegin_count) ;
899 reiserfs_write_unlock(dir->i_sb);
900 return err ? err : retval;
903 static int reiserfs_unlink (struct inode * dir, struct dentry *dentry)
906 struct inode * inode;
907 struct reiserfs_dir_entry de;
908 INITIALIZE_PATH (path);
909 struct reiserfs_transaction_handle th ;
911 unsigned long savelink;
913 inode = dentry->d_inode;
915 /* in this transaction we can be doing at max two balancings and update
916 two stat datas, we change quotas of the owner of the directory and of
917 the owner of the parent directory */
918 jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 + 2 * (REISERFS_QUOTA_INIT_BLOCKS+REISERFS_QUOTA_TRANS_BLOCKS);
920 reiserfs_write_lock(dir->i_sb);
921 retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
925 de.de_gen_number_bit_string = NULL;
926 if ( (retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de)) == NAME_NOT_FOUND) {
929 } else if (retval == IO_ERROR) {
934 reiserfs_update_inode_transaction(inode) ;
935 reiserfs_update_inode_transaction(dir) ;
937 if (de.de_objectid != inode->i_ino) {
938 // FIXME: compare key of an object and a key found in the
944 if (!inode->i_nlink) {
945 reiserfs_warning (inode->i_sb, "%s: deleting nonexistent file "
946 "(%s:%lu), %d", __FUNCTION__,
947 reiserfs_bdevname (inode->i_sb), inode->i_ino,
955 * we schedule before doing the add_save_link call, save the link
956 * count so we don't race
958 savelink = inode->i_nlink;
961 retval = reiserfs_cut_from_item (&th, &path, &(de.de_entry_key), dir, NULL, 0);
966 inode->i_ctime = CURRENT_TIME_SEC;
967 reiserfs_update_sd (&th, inode);
969 dir->i_size -= (de.de_entrylen + DEH_SIZE);
970 dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
971 reiserfs_update_sd (&th, dir);
974 /* prevent file from getting lost */
975 add_save_link (&th, inode, 0/* not truncate */);
977 retval = journal_end(&th, dir->i_sb, jbegin_count) ;
978 reiserfs_check_path(&path) ;
979 reiserfs_write_unlock(dir->i_sb);
984 err = journal_end(&th, dir->i_sb, jbegin_count) ;
985 reiserfs_check_path(&path) ;
989 reiserfs_write_unlock(dir->i_sb);
993 static int reiserfs_symlink (struct inode * parent_dir,
994 struct dentry * dentry, const char * symname)
997 struct inode * inode;
1000 struct reiserfs_transaction_handle th ;
1001 int mode = S_IFLNK | S_IRWXUGO;
1002 /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
1003 int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * (REISERFS_QUOTA_INIT_BLOCKS+REISERFS_QUOTA_TRANS_BLOCKS);
1005 if (!(inode = new_inode(parent_dir->i_sb))) {
1008 new_inode_init(inode, parent_dir, mode);
1010 reiserfs_write_lock(parent_dir->i_sb);
1011 item_len = ROUND_UP (strlen (symname));
1012 if (item_len > MAX_DIRECT_ITEM_LEN (parent_dir->i_sb->s_blocksize)) {
1013 retval = -ENAMETOOLONG;
1014 drop_new_inode(inode);
1018 name = reiserfs_kmalloc (item_len, GFP_NOFS, parent_dir->i_sb);
1020 drop_new_inode(inode);
1024 memcpy (name, symname, strlen (symname));
1025 padd_item (name, item_len, strlen (symname));
1027 /* We would inherit the default ACL here, but symlinks don't get ACLs */
1029 retval = journal_begin(&th, parent_dir->i_sb, jbegin_count) ;
1031 drop_new_inode (inode);
1032 reiserfs_kfree (name, item_len, parent_dir->i_sb);
1036 retval = reiserfs_new_inode (&th, parent_dir, mode, name, strlen (symname),
1038 reiserfs_kfree (name, item_len, parent_dir->i_sb);
1039 if (retval) { /* reiserfs_new_inode iputs for us */
1043 reiserfs_update_inode_transaction(inode) ;
1044 reiserfs_update_inode_transaction(parent_dir) ;
1046 inode->i_op = &reiserfs_symlink_inode_operations;
1047 inode->i_mapping->a_ops = &reiserfs_address_space_operations;
1049 // must be sure this inode is written with this transaction
1051 //reiserfs_update_sd (&th, inode, READ_BLOCKS);
1053 retval = reiserfs_add_entry (&th, parent_dir, dentry->d_name.name,
1054 dentry->d_name.len, inode, 1/*visible*/);
1058 reiserfs_update_sd (&th, inode);
1059 err = journal_end(&th, parent_dir->i_sb, jbegin_count) ;
1066 d_instantiate(dentry, inode);
1067 retval = journal_end(&th, parent_dir->i_sb, jbegin_count) ;
1069 reiserfs_write_unlock(parent_dir->i_sb);
1073 static int reiserfs_link (struct dentry * old_dentry, struct inode * dir, struct dentry * dentry)
1076 struct inode *inode = old_dentry->d_inode;
1077 struct reiserfs_transaction_handle th ;
1078 /* We need blocks for transaction + update of quotas for the owners of the directory */
1079 int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * REISERFS_QUOTA_TRANS_BLOCKS;
1081 reiserfs_write_lock(dir->i_sb);
1082 if (inode->i_nlink >= REISERFS_LINK_MAX) {
1083 //FIXME: sd_nlink is 32 bit for new files
1084 reiserfs_write_unlock(dir->i_sb);
1087 if (inode->i_nlink == 0) {
1088 reiserfs_write_unlock(dir->i_sb);
1092 /* inc before scheduling so reiserfs_unlink knows we are here */
1095 retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
1098 reiserfs_write_unlock (dir->i_sb);
1102 /* create new entry */
1103 retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
1104 inode, 1/*visible*/);
1106 reiserfs_update_inode_transaction(inode) ;
1107 reiserfs_update_inode_transaction(dir) ;
1112 err = journal_end(&th, dir->i_sb, jbegin_count) ;
1113 reiserfs_write_unlock(dir->i_sb);
1114 return err ? err : retval;
1117 inode->i_ctime = CURRENT_TIME_SEC;
1118 reiserfs_update_sd (&th, inode);
1120 atomic_inc(&inode->i_count) ;
1121 d_instantiate(dentry, inode);
1122 retval = journal_end(&th, dir->i_sb, jbegin_count) ;
1123 reiserfs_write_unlock(dir->i_sb);
1128 // de contains information pointing to an entry which
1129 static int de_still_valid (const char * name, int len, struct reiserfs_dir_entry * de)
1131 struct reiserfs_dir_entry tmp = *de;
1133 // recalculate pointer to name and name length
1134 set_de_name_and_namelen (&tmp);
1135 // FIXME: could check more
1136 if (tmp.de_namelen != len || memcmp (name, de->de_name, len))
1142 static int entry_points_to_object (const char * name, int len, struct reiserfs_dir_entry * de, struct inode * inode)
1144 if (!de_still_valid (name, len, de))
1148 if (!de_visible (de->de_deh + de->de_entry_num))
1149 reiserfs_panic (NULL, "vs-7042: entry_points_to_object: entry must be visible");
1150 return (de->de_objectid == inode->i_ino) ? 1 : 0;
1153 /* this must be added hidden entry */
1154 if (de_visible (de->de_deh + de->de_entry_num))
1155 reiserfs_panic (NULL, "vs-7043: entry_points_to_object: entry must be visible");
1161 /* sets key of objectid the entry has to point to */
1162 static void set_ino_in_dir_entry (struct reiserfs_dir_entry * de, struct reiserfs_key * key)
1164 /* JDM These operations are endian safe - both are le */
1165 de->de_deh[de->de_entry_num].deh_dir_id = key->k_dir_id;
1166 de->de_deh[de->de_entry_num].deh_objectid = key->k_objectid;
1171 * process, that is going to call fix_nodes/do_balance must hold only
1172 * one path. If it holds 2 or more, it can get into endless waiting in
1173 * get_empty_nodes or its clones
1175 static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
1176 struct inode * new_dir, struct dentry *new_dentry)
1179 INITIALIZE_PATH (old_entry_path);
1180 INITIALIZE_PATH (new_entry_path);
1181 INITIALIZE_PATH (dot_dot_entry_path);
1182 struct item_head new_entry_ih, old_entry_ih, dot_dot_ih ;
1183 struct reiserfs_dir_entry old_de, new_de, dot_dot_de;
1184 struct inode * old_inode, * new_dentry_inode;
1185 struct reiserfs_transaction_handle th ;
1187 umode_t old_inode_mode;
1188 unsigned long savelink = 1;
1189 struct timespec ctime;
1191 /* three balancings: (1) old name removal, (2) new name insertion
1192 and (3) maybe "save" link insertion
1193 stat data updates: (1) old directory,
1194 (2) new directory and (3) maybe old object stat data (when it is
1195 directory) and (4) maybe stat data of object to which new entry
1196 pointed initially and (5) maybe block containing ".." of
1198 quota updates: two parent directories */
1199 jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 5 + 4 * REISERFS_QUOTA_TRANS_BLOCKS;
1201 old_inode = old_dentry->d_inode;
1202 new_dentry_inode = new_dentry->d_inode;
1204 // make sure, that oldname still exists and points to an object we
1205 // are going to rename
1206 old_de.de_gen_number_bit_string = NULL;
1207 reiserfs_write_lock(old_dir->i_sb);
1208 retval = reiserfs_find_entry (old_dir, old_dentry->d_name.name, old_dentry->d_name.len,
1209 &old_entry_path, &old_de);
1210 pathrelse (&old_entry_path);
1211 if (retval == IO_ERROR) {
1212 reiserfs_write_unlock(old_dir->i_sb);
1216 if (retval != NAME_FOUND || old_de.de_objectid != old_inode->i_ino) {
1217 reiserfs_write_unlock(old_dir->i_sb);
1221 old_inode_mode = old_inode->i_mode;
1222 if (S_ISDIR(old_inode_mode)) {
1223 // make sure, that directory being renamed has correct ".."
1224 // and that its new parent directory has not too many links
1227 if (new_dentry_inode) {
1228 if (!reiserfs_empty_dir(new_dentry_inode)) {
1229 reiserfs_write_unlock(old_dir->i_sb);
1234 /* directory is renamed, its parent directory will be changed,
1235 ** so find ".." entry
1237 dot_dot_de.de_gen_number_bit_string = NULL;
1238 retval = reiserfs_find_entry (old_inode, "..", 2, &dot_dot_entry_path, &dot_dot_de);
1239 pathrelse (&dot_dot_entry_path);
1240 if (retval != NAME_FOUND) {
1241 reiserfs_write_unlock(old_dir->i_sb);
1245 /* inode number of .. must equal old_dir->i_ino */
1246 if (dot_dot_de.de_objectid != old_dir->i_ino) {
1247 reiserfs_write_unlock(old_dir->i_sb);
1252 retval = journal_begin(&th, old_dir->i_sb, jbegin_count) ;
1254 reiserfs_write_unlock (old_dir->i_sb);
1258 /* add new entry (or find the existing one) */
1259 retval = reiserfs_add_entry (&th, new_dir, new_dentry->d_name.name, new_dentry->d_name.len,
1261 if (retval == -EEXIST) {
1262 if (!new_dentry_inode) {
1263 reiserfs_panic (old_dir->i_sb,
1264 "vs-7050: new entry is found, new inode == 0\n");
1266 } else if (retval) {
1267 int err = journal_end(&th, old_dir->i_sb, jbegin_count) ;
1268 reiserfs_write_unlock(old_dir->i_sb);
1269 return err ? err : retval;
1272 reiserfs_update_inode_transaction(old_dir) ;
1273 reiserfs_update_inode_transaction(new_dir) ;
1275 /* this makes it so an fsync on an open fd for the old name will
1276 ** commit the rename operation
1278 reiserfs_update_inode_transaction(old_inode) ;
1280 if (new_dentry_inode)
1281 reiserfs_update_inode_transaction(new_dentry_inode) ;
1284 // look for old name using corresponding entry key (found by reiserfs_find_entry)
1285 if ((retval = search_by_entry_key (new_dir->i_sb, &old_de.de_entry_key,
1286 &old_entry_path, &old_de)) != NAME_FOUND) {
1287 pathrelse(&old_entry_path);
1288 journal_end(&th, old_dir->i_sb, jbegin_count);
1289 reiserfs_write_unlock(old_dir->i_sb);
1293 copy_item_head(&old_entry_ih, get_ih(&old_entry_path)) ;
1295 reiserfs_prepare_for_journal(old_inode->i_sb, old_de.de_bh, 1) ;
1297 // look for new name by reiserfs_find_entry
1298 new_de.de_gen_number_bit_string = NULL;
1299 retval = reiserfs_find_entry (new_dir, new_dentry->d_name.name, new_dentry->d_name.len,
1300 &new_entry_path, &new_de);
1301 // reiserfs_add_entry should not return IO_ERROR, because it is called with essentially same parameters from
1302 // reiserfs_add_entry above, and we'll catch any i/o errors before we get here.
1303 if (retval != NAME_FOUND_INVISIBLE && retval != NAME_FOUND) {
1304 pathrelse(&new_entry_path);
1305 pathrelse(&old_entry_path);
1306 journal_end(&th, old_dir->i_sb, jbegin_count);
1307 reiserfs_write_unlock(old_dir->i_sb);
1311 copy_item_head(&new_entry_ih, get_ih(&new_entry_path)) ;
1313 reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1) ;
1315 if (S_ISDIR(old_inode->i_mode)) {
1316 if ((retval = search_by_entry_key (new_dir->i_sb, &dot_dot_de.de_entry_key,
1317 &dot_dot_entry_path, &dot_dot_de)) != NAME_FOUND) {
1318 pathrelse(&dot_dot_entry_path);
1319 pathrelse(&new_entry_path);
1320 pathrelse(&old_entry_path);
1321 journal_end(&th, old_dir->i_sb, jbegin_count);
1322 reiserfs_write_unlock(old_dir->i_sb);
1325 copy_item_head(&dot_dot_ih, get_ih(&dot_dot_entry_path)) ;
1326 // node containing ".." gets into transaction
1327 reiserfs_prepare_for_journal(old_inode->i_sb, dot_dot_de.de_bh, 1) ;
1329 /* we should check seals here, not do
1330 this stuff, yes? Then, having
1331 gathered everything into RAM we
1332 should lock the buffers, yes? -Hans */
1333 /* probably. our rename needs to hold more
1334 ** than one path at once. The seals would
1335 ** have to be written to deal with multi-path
1338 /* sanity checking before doing the rename - avoid races many
1339 ** of the above checks could have scheduled. We have to be
1340 ** sure our items haven't been shifted by another process.
1342 if (item_moved(&new_entry_ih, &new_entry_path) ||
1343 !entry_points_to_object(new_dentry->d_name.name,
1344 new_dentry->d_name.len,
1345 &new_de, new_dentry_inode) ||
1346 item_moved(&old_entry_ih, &old_entry_path) ||
1347 !entry_points_to_object (old_dentry->d_name.name,
1348 old_dentry->d_name.len,
1349 &old_de, old_inode)) {
1350 reiserfs_restore_prepared_buffer (old_inode->i_sb, new_de.de_bh);
1351 reiserfs_restore_prepared_buffer (old_inode->i_sb, old_de.de_bh);
1352 if (S_ISDIR(old_inode_mode))
1353 reiserfs_restore_prepared_buffer (old_inode->i_sb, dot_dot_de.de_bh);
1356 if (S_ISDIR(old_inode_mode)) {
1357 if ( item_moved(&dot_dot_ih, &dot_dot_entry_path) ||
1358 !entry_points_to_object ( "..", 2, &dot_dot_de, old_dir) ) {
1359 reiserfs_restore_prepared_buffer (old_inode->i_sb, old_de.de_bh);
1360 reiserfs_restore_prepared_buffer (old_inode->i_sb, new_de.de_bh);
1361 reiserfs_restore_prepared_buffer (old_inode->i_sb, dot_dot_de.de_bh);
1366 RFALSE( S_ISDIR(old_inode_mode) &&
1367 !buffer_journal_prepared(dot_dot_de.de_bh), "" );
1372 /* ok, all the changes can be done in one fell swoop when we
1373 have claimed all the buffers needed.*/
1375 mark_de_visible (new_de.de_deh + new_de.de_entry_num);
1376 set_ino_in_dir_entry (&new_de, INODE_PKEY (old_inode));
1377 journal_mark_dirty (&th, old_dir->i_sb, new_de.de_bh);
1379 mark_de_hidden (old_de.de_deh + old_de.de_entry_num);
1380 journal_mark_dirty (&th, old_dir->i_sb, old_de.de_bh);
1381 ctime = CURRENT_TIME_SEC;
1382 old_dir->i_ctime = old_dir->i_mtime = ctime;
1383 new_dir->i_ctime = new_dir->i_mtime = ctime;
1384 /* thanks to Alex Adriaanse <alex_a@caltech.edu> for patch which adds ctime update of
1386 old_inode->i_ctime = ctime;
1388 if (new_dentry_inode) {
1389 // adjust link number of the victim
1390 if (S_ISDIR(new_dentry_inode->i_mode)) {
1391 new_dentry_inode->i_nlink = 0;
1393 new_dentry_inode->i_nlink--;
1395 new_dentry_inode->i_ctime = ctime;
1396 savelink = new_dentry_inode->i_nlink;
1399 if (S_ISDIR(old_inode_mode)) {
1400 // adjust ".." of renamed directory
1401 set_ino_in_dir_entry (&dot_dot_de, INODE_PKEY (new_dir));
1402 journal_mark_dirty (&th, new_dir->i_sb, dot_dot_de.de_bh);
1404 if (!new_dentry_inode)
1405 /* there (in new_dir) was no directory, so it got new link
1406 (".." of renamed directory) */
1407 INC_DIR_INODE_NLINK(new_dir);
1409 /* old directory lost one link - ".. " of renamed directory */
1410 DEC_DIR_INODE_NLINK(old_dir);
1413 // looks like in 2.3.99pre3 brelse is atomic. so we can use pathrelse
1414 pathrelse (&new_entry_path);
1415 pathrelse (&dot_dot_entry_path);
1417 // FIXME: this reiserfs_cut_from_item's return value may screw up
1418 // anybody, but it will panic if will not be able to find the
1419 // entry. This needs one more clean up
1420 if (reiserfs_cut_from_item (&th, &old_entry_path, &(old_de.de_entry_key), old_dir, NULL, 0) < 0)
1421 reiserfs_warning (old_dir->i_sb, "vs-7060: reiserfs_rename: couldn't not cut old name. Fsck later?");
1423 old_dir->i_size -= DEH_SIZE + old_de.de_entrylen;
1425 reiserfs_update_sd (&th, old_dir);
1426 reiserfs_update_sd (&th, new_dir);
1427 reiserfs_update_sd (&th, old_inode);
1429 if (new_dentry_inode) {
1431 add_save_link (&th, new_dentry_inode, 0/* not truncate */);
1432 reiserfs_update_sd (&th, new_dentry_inode);
1435 retval = journal_end(&th, old_dir->i_sb, jbegin_count) ;
1436 reiserfs_write_unlock(old_dir->i_sb);
1441 * directories can handle most operations...
1443 struct inode_operations reiserfs_dir_inode_operations = {
1444 //&reiserfs_dir_operations, /* default_file_ops */
1445 .create = reiserfs_create,
1446 .lookup = reiserfs_lookup,
1447 .link = reiserfs_link,
1448 .unlink = reiserfs_unlink,
1449 .symlink = reiserfs_symlink,
1450 .mkdir = reiserfs_mkdir,
1451 .rmdir = reiserfs_rmdir,
1452 .mknod = reiserfs_mknod,
1453 .rename = reiserfs_rename,
1454 .setattr = reiserfs_setattr,
1455 .setxattr = reiserfs_setxattr,
1456 .getxattr = reiserfs_getxattr,
1457 .listxattr = reiserfs_listxattr,
1458 .removexattr = reiserfs_removexattr,
1459 .permission = reiserfs_permission,
1463 * symlink operations.. same as page_symlink_inode_operations, with xattr
1466 struct inode_operations reiserfs_symlink_inode_operations = {
1467 .readlink = generic_readlink,
1468 .follow_link = page_follow_link_light,
1469 .put_link = page_put_link,
1470 .setattr = reiserfs_setattr,
1471 .setxattr = reiserfs_setxattr,
1472 .getxattr = reiserfs_getxattr,
1473 .listxattr = reiserfs_listxattr,
1474 .removexattr = reiserfs_removexattr,
1475 .permission = reiserfs_permission,
1481 * special file operations.. just xattr/acl stuff
1483 struct inode_operations reiserfs_special_inode_operations = {
1484 .setattr = reiserfs_setattr,
1485 .setxattr = reiserfs_setxattr,
1486 .getxattr = reiserfs_getxattr,
1487 .listxattr = reiserfs_listxattr,
1488 .removexattr = reiserfs_removexattr,
1489 .permission = reiserfs_permission,