patch-2.4.13 linux/fs/reiserfs/namei.c
Next file: linux/fs/reiserfs/objectid.c
Previous file: linux/fs/reiserfs/lbalance.c
Back to the patch index
Back to the overall index
- Lines: 211
- Date:
Fri Oct 12 14:20:42 2001
- Orig file:
v2.4.12/linux/fs/reiserfs/namei.c
- Orig date:
Tue Oct 9 17:06:53 2001
diff -u --recursive --new-file v2.4.12/linux/fs/reiserfs/namei.c linux/fs/reiserfs/namei.c
@@ -81,7 +81,7 @@
de->de_entrylen = entry_length (de->de_bh, de->de_ih, de->de_entry_num);
de->de_namelen = de->de_entrylen - (de_with_sd (deh) ? SD_SIZE : 0);
- de->de_name = B_I_PITEM (de->de_bh, de->de_ih) + le16_to_cpu (deh->deh_location);
+ de->de_name = B_I_PITEM (de->de_bh, de->de_ih) + deh_location(deh);
if (de->de_name[de->de_namelen - 1] == 0)
de->de_namelen = strlen (de->de_name);
}
@@ -92,8 +92,8 @@
{
if (de->de_entry_num >= ih_entry_count (de->de_ih))
BUG ();
- de->de_dir_id = le32_to_cpu (de->de_deh[de->de_entry_num].deh_dir_id);
- de->de_objectid = le32_to_cpu (de->de_deh[de->de_entry_num].deh_objectid);
+ de->de_dir_id = deh_dir_id( &(de->de_deh[de->de_entry_num]));
+ de->de_objectid = deh_objectid( &(de->de_deh[de->de_entry_num]));
}
@@ -159,7 +159,7 @@
COMP_SHORT_KEYS (&(de->de_ih->ih_key), key)) {
print_block (de->de_bh, 0, -1, -1);
reiserfs_panic (sb, "vs-7005: search_by_entry_key: found item %h is not directory item or "
- "does not belong to the same directory as key %k", de->de_ih, key);
+ "does not belong to the same directory as key %K", de->de_ih, key);
}
#endif /* CONFIG_REISERFS_CHECK */
@@ -322,12 +322,7 @@
retval = search_by_entry_key (dir->i_sb, &key_to_search, path_to_entry, de);
if (retval == IO_ERROR)
// FIXME: still has to be dealt with
-
- /* I want you to conform to our error
- printing standard. How many times
- do I have to ask? -Hans */
-
- BUG ();
+ reiserfs_panic (dir->i_sb, "zam-7001: io error in " __FUNCTION__ "\n");
/* compare names for all entries having given hash value */
retval = linear_search_in_dir_item (&key_to_search, de, name, namelen);
@@ -434,12 +429,12 @@
/* fill buffer : directory entry head, name[, dir objectid | , stat data | ,stat data, dir objectid ] */
deh = (struct reiserfs_de_head *)buffer;
- deh->deh_location = 0;
- deh->deh_offset = cpu_to_le32 (cpu_key_k_offset (&entry_key));
- deh->deh_state = 0;
+ deh->deh_location = 0; /* JDM Endian safe if 0 */
+ put_deh_offset( deh, cpu_key_k_offset( &entry_key ) );
+ deh->deh_state = 0; /* JDM Endian safe if 0 */
/* put key (ino analog) to de */
- deh->deh_dir_id = INODE_PKEY (inode)->k_dir_id;
- deh->deh_objectid = INODE_PKEY (inode)->k_objectid;
+ deh->deh_dir_id = INODE_PKEY (inode)->k_dir_id; /* safe: k_dir_id is le */
+ deh->deh_objectid = INODE_PKEY (inode)->k_objectid; /* safe: k_objectid is le */
/* copy name */
memcpy ((char *)(deh + 1), name, namelen);
@@ -454,36 +449,37 @@
memset (bit_string, 0, sizeof (bit_string));
de.de_gen_number_bit_string = (char *)bit_string;
retval = reiserfs_find_entry (dir, name, namelen, &path, &de);
- if (retval != NAME_NOT_FOUND) {
+ if( retval != NAME_NOT_FOUND ) {
if (buffer != small_buf)
reiserfs_kfree (buffer, buflen, dir->i_sb);
pathrelse (&path);
-
- if (retval != NAME_FOUND) {
+
+ if (retval != NAME_FOUND) {
reiserfs_warning ("zam-7002:" __FUNCTION__ ": \"reiserfs_find_entry\" has returned"
- " unexpected value (%d)\n", retval);
- }
-
+ " unexpected value (%d)\n", retval);
+ }
+
return -EEXIST;
}
gen_number = find_first_zero_bit (bit_string, MAX_GENERATION_NUMBER + 1);
if (gen_number > MAX_GENERATION_NUMBER) {
- /* there is no free generation number */
- reiserfs_warning ("reiserfs_add_entry: Congratulations! we have got hash function screwed up\n");
- if (buffer != small_buf)
- reiserfs_kfree (buffer, buflen, dir->i_sb);
- pathrelse (&path);
- return -EBUSY;
+ /* there is no free generation number */
+ reiserfs_warning ("reiserfs_add_entry: Congratulations! we have got hash function screwed up\n");
+ if (buffer != small_buf)
+ reiserfs_kfree (buffer, buflen, dir->i_sb);
+ pathrelse (&path);
+ return -EBUSY;
}
/* adjust offset of directory enrty */
- deh->deh_offset = cpu_to_le32 (SET_GENERATION_NUMBER (deh_offset (deh), gen_number));
- set_cpu_key_k_offset (&entry_key, le32_to_cpu (deh->deh_offset));
-
+ put_deh_offset(deh, SET_GENERATION_NUMBER(deh_offset(deh), gen_number));
+ set_cpu_key_k_offset (&entry_key, deh_offset(deh));
+
if (gen_number != 0) { /* we need to re-search for the insertion point */
- if (search_by_entry_key (dir->i_sb, &entry_key, &path, &de) != NAME_NOT_FOUND) {
- reiserfs_warning ("vs-7032: reiserfs_add_entry: "
- "entry with this key (%k) already exists\n", &entry_key);
+ if (search_by_entry_key (dir->i_sb, &entry_key, &path, &de) != NAME_NOT_FOUND) {
+ reiserfs_warning ("vs-7032: reiserfs_add_entry: "
+ "entry with this key (%k) already exists\n", &entry_key);
+
if (buffer != small_buf)
reiserfs_kfree (buffer, buflen, dir->i_sb);
pathrelse (&path);
@@ -558,6 +554,8 @@
iput (inode);
return retval;
}
+ reiserfs_update_inode_transaction(inode) ;
+ reiserfs_update_inode_transaction(dir) ;
d_instantiate(dentry, inode);
pop_journal_writer(windex) ;
@@ -600,6 +598,9 @@
//FIXME: needed for block and char devices only
reiserfs_update_sd (&th, inode);
+ reiserfs_update_inode_transaction(inode) ;
+ reiserfs_update_inode_transaction(dir) ;
+
retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
inode, 1/*visible*/);
if (retval) {
@@ -655,6 +656,8 @@
journal_end(&th, dir->i_sb, jbegin_count) ;
return retval;
}
+ reiserfs_update_inode_transaction(inode) ;
+ reiserfs_update_inode_transaction(dir) ;
inode->i_op = &reiserfs_dir_inode_operations;
inode->i_fop = &reiserfs_dir_operations;
@@ -723,6 +726,9 @@
}
inode = dentry->d_inode;
+ reiserfs_update_inode_transaction(inode) ;
+ reiserfs_update_inode_transaction(dir) ;
+
if (de.de_objectid != inode->i_ino) {
// FIXME: compare key of an object and a key found in the
// entry
@@ -796,6 +802,9 @@
}
inode = dentry->d_inode;
+ reiserfs_update_inode_transaction(inode) ;
+ reiserfs_update_inode_transaction(dir) ;
+
if (de.de_objectid != inode->i_ino) {
// FIXME: compare key of an object and a key found in the
// entry
@@ -885,6 +894,9 @@
return retval;
}
+ reiserfs_update_inode_transaction(inode) ;
+ reiserfs_update_inode_transaction(dir) ;
+
inode->i_op = &page_symlink_inode_operations;
inode->i_mapping->a_ops = &reiserfs_address_space_operations;
@@ -940,6 +952,10 @@
/* create new entry */
retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
inode, 1/*visible*/);
+
+ reiserfs_update_inode_transaction(inode) ;
+ reiserfs_update_inode_transaction(dir) ;
+
if (retval) {
pop_journal_writer(windex) ;
journal_end(&th, dir->i_sb, jbegin_count) ;
@@ -994,6 +1010,7 @@
/* sets key of objectid the entry has to point to */
static void set_ino_in_dir_entry (struct reiserfs_dir_entry * de, struct key * key)
{
+ /* JDM These operations are endian safe - both are le */
de->de_deh[de->de_entry_num].deh_dir_id = key->k_dir_id;
de->de_deh[de->de_entry_num].deh_objectid = key->k_objectid;
}
@@ -1085,6 +1102,16 @@
return retval;
}
+ reiserfs_update_inode_transaction(old_dir) ;
+ reiserfs_update_inode_transaction(new_dir) ;
+
+ /* this makes it so an fsync on an open fd for the old name will
+ ** commit the rename operation
+ */
+ reiserfs_update_inode_transaction(old_inode) ;
+
+ if (new_inode)
+ reiserfs_update_inode_transaction(new_inode) ;
while (1) {
// look for old name using corresponding entry key (found by reiserfs_find_entry)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)