diff -rup -X dontdiff linux/fs/reiserfs/dir.c linux.patched/fs/reiserfs/dir.c
--- linux/fs/reiserfs/dir.c Wed Nov 21 15:23:20 2001
+++ linux.patched/fs/reiserfs/dir.c Wed Nov 21 15:21:36 2001
@@ -170,7 +170,7 @@ static int reiserfs_readdir (struct file
}
/* directory continues in the right neighboring block */
- set_cpu_key_k_offset (&pos_key, le_key_k_offset (ITEM_VERSION_1, rkey));
+ set_cpu_key_k_offset (&pos_key, le_key_k_offset (KEY_FORMAT_3_5, rkey));
} /* while */
diff -rup -X dontdiff linux/fs/reiserfs/file.c linux.patched/fs/reiserfs/file.c
--- linux/fs/reiserfs/file.c Wed Nov 21 15:23:20 2001
+++ linux.patched/fs/reiserfs/file.c Wed Nov 21 15:22:24 2001
@@ -33,7 +33,7 @@ static int reiserfs_file_release (struct
/* fast out for when nothing needs to be done */
if ((atomic_read(&inode->i_count) > 1 ||
- !inode->u.reiserfs_i.i_pack_on_close ||
+ !(inode->u.reiserfs_i.i_flags & i_pack_on_close_mask) ||
!tail_has_to_be_packed(inode)) &&
inode->u.reiserfs_i.i_prealloc_count <= 0) {
return 0;
@@ -50,7 +50,7 @@ static int reiserfs_file_release (struct
journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3) ;
if (atomic_read(&inode->i_count) <= 1 &&
- inode->u.reiserfs_i.i_pack_on_close &&
+ (inode->u.reiserfs_i.i_flags & i_pack_on_close_mask) &&
tail_has_to_be_packed (inode)) {
/* if regular file is released by last holder and it has been
appended (we append by unformatted node only) or its direct
@@ -97,7 +97,7 @@ static int reiserfs_setattr(struct dentr
/* version 2 items will be caught by the s_maxbytes check
** done for us in vmtruncate
*/
- if (inode_items_version(inode) == ITEM_VERSION_1 &&
+ if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5 &&
attr->ia_size > MAX_NON_LFS)
return -EFBIG ;
- up (&inode->i_sem);
+ up (&inode->i_sem);
+
+ /* all items of file are deleted, so we can remove "save" link */
+ remove_save_link (inode, 0/* not truncate */);
} else {
/* no object items are in the tree */
;
@@ -74,9 +76,9 @@ static void _make_cpu_key (struct cpu_ke
void make_cpu_key (struct cpu_key * key, const struct inode * inode, loff_t offset,
int type, int length )
{
- _make_cpu_key (key, inode_items_version (inode), le32_to_cpu (INODE_PKEY (inode)->k_dir_id),
- le32_to_cpu (INODE_PKEY (inode)->k_objectid),
- offset, type, length);
+ _make_cpu_key (key, get_inode_item_key_version (inode), le32_to_cpu (INODE_PKEY (inode)->k_dir_id),
+ le32_to_cpu (INODE_PKEY (inode)->k_objectid),
+ offset, type, length);
}
@@ -219,7 +221,7 @@ static inline void set_block_dev_mapped
//
int file_capable (struct inode * inode, long block)
{
- if (inode_items_version (inode) != ITEM_VERSION_1 || // it is new file.
+ if (get_inode_item_key_version (inode) != KEY_FORMAT_3_5 || // it is new file.
block < (1 << (31 - inode->i_sb->s_blocksize_bits))) // old file, but 'block' is inside of 2gb
return 1;
@@ -542,7 +544,7 @@ static int reiserfs_get_block (struct in
/* bad.... */
lock_kernel() ;
th.t_trans_id = 0 ;
- version = inode_items_version (inode);
+ version = get_inode_item_key_version (inode);
if (block < 0) {
unlock_kernel();
@@ -566,7 +568,7 @@ static int reiserfs_get_block (struct in
return ret;
}
/* set version 1, version 2 could be used too, because stat data
key is the same in both versions */
- key.version = ITEM_VERSION_1;
+ key.version = KEY_FORMAT_3_5;
key.on_disk_key.k_dir_id = dirino;
key.on_disk_key.k_objectid = inode->i_ino;
key.on_disk_key.u.k_offset_v1.k_offset = SD_OFFSET;
@@ -1347,20 +1350,20 @@ static int reiserfs_new_directory (struc
struct cpu_key key;
int retval;
/* compose item head for new item. Directories consist of items of
old type (ITEM_VERSION_1). Do not set key (second arg is 0), it
is done by reiserfs_new_inode */
if (old_format_only (sb)) {
- make_le_item_head (ih, 0, ITEM_VERSION_1, DOT_OFFSET, TYPE_DIRENTRY, EMPTY_DIR_SIZE_V1, 2);
+ make_le_item_head (ih, 0, KEY_FORMAT_3_5, DOT_OFFSET, TYPE_DIRENTRY, EMPTY_DIR_SIZE_V1, 2);
/* look for place in the tree for new item */
retval = search_item (sb, &key, path);
@@ -1472,13 +1475,13 @@ struct inode * reiserfs_new_inode (struc
inode->i_generation = ++event;
#endif
if (old_format_only (sb))
- make_le_item_head (&ih, 0, ITEM_VERSION_1, SD_OFFSET, TYPE_STAT_DATA, SD_V1_SIZE, MAX_US_INT);
+ make_le_item_head (&ih, 0, KEY_FORMAT_3_5, SD_OFFSET, TYPE_STAT_DATA, SD_V1_SIZE, MAX_US_INT);
else
- make_le_item_head (&ih, 0, ITEM_VERSION_2, SD_OFFSET, TYPE_STAT_DATA, SD_SIZE, MAX_US_INT);
+ make_le_item_head (&ih, 0, KEY_FORMAT_3_6, SD_OFFSET, TYPE_STAT_DATA, SD_SIZE, MAX_US_INT);
/* key to search for correct place for new stat data */
- _make_cpu_key (&key, ITEM_VERSION_2, le32_to_cpu (ih.ih_key.k_dir_id),
+ _make_cpu_key (&key, KEY_FORMAT_3_6, le32_to_cpu (ih.ih_key.k_dir_id),
le32_to_cpu (ih.ih_key.k_objectid), SD_OFFSET, TYPE_STAT_DATA, 3/*key length*/);
/* find proper place for inserting of stat data */
@@ -1529,10 +1532,14 @@ struct inode * reiserfs_new_inode (struc
// format, other new objects will consist of new items)
memcpy (INODE_PKEY (inode), &(ih.ih_key), KEY_SIZE);
if (old_format_only (sb) || S_ISDIR(mode) || S_ISLNK(mode))
- inode_items_version (inode) = ITEM_VERSION_1;
+ set_inode_item_key_version (inode, KEY_FORMAT_3_5);
else
- inode_items_version (inode) = ITEM_VERSION_2;
-
+ set_inode_item_key_version (inode, KEY_FORMAT_3_6);
+ if (old_format_only (sb))
+ set_inode_sd_version (inode, STAT_DATA_V1);
+ else
+ set_inode_sd_version (inode, STAT_DATA_V2);
+
/* insert the stat data into the tree */
retval = reiserfs_insert_item (th, &path_to_key, &key, &ih, (char *)(&sd));
if (retval) {
@@ -1692,12 +1699,23 @@ void reiserfs_truncate_file(struct inode
** because the truncate might pack the item anyway
** (it will unmap bh if it packs).
*/
- journal_begin(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 ) ;
+ /* it is enough to reserve space in transaction for 2 balancings:
+ one for "save" link adding and another for the first
+ cut_from_item. 1 is for update_sd */
+ journal_begin(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1 ) ;
reiserfs_update_inode_transaction(p_s_inode) ;
windex = push_journal_writer("reiserfs_vfs_truncate_file") ;
+ if (update_timestamps)
+ /* we are doing real truncate: if the system crashes before the last
+ transaction of truncating gets committed - on reboot the file
+ either appears truncated properly or not truncated at all */
+ add_save_link (&th, p_s_inode, 1);
reiserfs_do_truncate (&th, p_s_inode, page, update_timestamps) ;
pop_journal_writer(windex) ;
- journal_end(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 ) ;
+ journal_end(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1 ) ;
+
+ if (update_timestamps)
+ remove_save_link (p_s_inode, 1/* truncate */);
if (page) {
length = offset & (blocksize - 1) ;
diff -rup -X dontdiff linux/fs/reiserfs/ioctl.c linux.patched/fs/reiserfs/ioctl.c
--- linux/fs/reiserfs/ioctl.c Wed Nov 21 15:23:20 2001
+++ linux.patched/fs/reiserfs/ioctl.c Wed Nov 21 15:21:36 2001
@@ -46,7 +46,7 @@ int reiserfs_unpack (struct inode * inod
return -EINVAL ;
}
/* ioctl already done */
- if (inode->u.reiserfs_i.nopack) {
+ if (inode->u.reiserfs_i.i_flags & i_nopack_mask) {
return 0 ;
}
lock_kernel();
@@ -59,7 +59,7 @@ int reiserfs_unpack (struct inode * inod
write_from = inode->i_size & (blocksize - 1) ;
/* if we are on a block boundary, we are already unpacked. */
if ( write_from == 0) {
- inode->u.reiserfs_i.nopack = 1;
+ inode->u.reiserfs_i.i_flags |= i_nopack_mask;
goto out ;
}
@@ -79,7 +79,7 @@ int reiserfs_unpack (struct inode * inod
/* conversion can change page contents, must flush */
flush_dcache_page(page) ;
- inode->u.reiserfs_i.nopack = 1;
+ inode->u.reiserfs_i.i_flags |= i_nopack_mask;
kunmap(page) ; /* mapped by prepare_write */
out_unlock:
diff -rup -X dontdiff linux/fs/reiserfs/journal.c linux.patched/fs/reiserfs/journal.c
--- linux/fs/reiserfs/journal.c Wed Nov 21 15:23:20 2001
+++ linux.patched/fs/reiserfs/journal.c Wed Nov 21 15:22:10 2001
@@ -92,6 +92,8 @@ static int do_journal_end(struct reiserf
static int flush_journal_list(struct super_block *s, struct reiserfs_journal_list *jl, int flushall) ;
static int flush_commit_list(struct super_block *s, struct reiserfs_journal_list *jl, int flushall) ;
static int can_dirty(struct reiserfs_journal_cnode *cn) ;
+static int remove_from_journal_list(struct super_block *s, struct reiserfs_journal_list *jl, struct buffer_head *bh, int remove_freed);
+static int journal_join(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks);
-int journal_join(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks) {
+static int journal_join(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks) {
return do_journal_begin_r(th, p_s_sb, nblocks, 1) ;
}
@@ -2238,7 +2240,7 @@ int journal_end(struct reiserfs_transact
**
** returns 1 if it cleaned and relsed the buffer. 0 otherwise
*/
-int remove_from_transaction(struct super_block *p_s_sb, unsigned long blocknr, int already_cleaned) {
+static int remove_from_transaction(struct super_block *p_s_sb, unsigned long blocknr, int already_cleaned) {
struct buffer_head *bh ;
struct reiserfs_journal_cnode *cn ;
int ret = 0;
@@ -2279,7 +2281,7 @@ int remove_from_transaction(struct super
}
/* removes from a specific journal list hash */
-int remove_from_journal_list(struct super_block *s, struct reiserfs_journal_list *jl, struct buffer_head *bh, int remove_freed) {
+static int remove_from_journal_list(struct super_block *s, struct reiserfs_journal_list *jl, struct buffer_head *bh, int remove_freed) {
remove_journal_hash(SB_JOURNAL(s)->j_list_hash_table, jl, bh, remove_freed) ;
return 0 ;
}
diff -rup -X dontdiff linux/fs/reiserfs/lbalance.c linux.patched/fs/reiserfs/lbalance.c
--- linux/fs/reiserfs/lbalance.c Wed Nov 21 15:23:20 2001
+++ linux.patched/fs/reiserfs/lbalance.c Tue Nov 20 22:47:11 2001
@@ -63,7 +63,7 @@ static void leaf_copy_dir_entries (struc
/* form item header */
memcpy (&new_ih.ih_key, &ih->ih_key, KEY_SIZE);
- put_ih_version( &new_ih, ITEM_VERSION_1 );
+ put_ih_version( &new_ih, KEY_FORMAT_3_5 );
/* calculate item len */
put_ih_item_len( &new_ih, DEH_SIZE * copy_count + copy_records_len );
put_ih_entry_count( &new_ih, 0 );
@@ -78,7 +78,7 @@ static void leaf_copy_dir_entries (struc
set_le_ih_k_offset (&new_ih, U32_MAX);
/* this item is not yet valid, but we want I_IS_DIRECTORY_ITEM to return 1 for it, so we -1 */
}
- set_le_key_k_type (ITEM_VERSION_1, &(new_ih.ih_key), TYPE_DIRENTRY);
+ set_le_key_k_type (KEY_FORMAT_3_5, &(new_ih.ih_key), TYPE_DIRENTRY);
}
/* insert item into dest buffer */
diff -rup -X dontdiff linux/fs/reiserfs/namei.c linux.patched/fs/reiserfs/namei.c
--- linux/fs/reiserfs/namei.c Wed Nov 21 15:23:20 2001
+++ linux.patched/fs/reiserfs/namei.c Tue Nov 20 22:47:11 2001
@@ -94,7 +94,7 @@ static inline void store_de_entry_key (s
BUG ();
/* store key of the found entry */
- de->de_entry_key.version = ITEM_VERSION_1;
+ de->de_entry_key.version = KEY_FORMAT_3_5;
de->de_entry_key.on_disk_key.k_dir_id = le32_to_cpu (de->de_ih->ih_key.k_dir_id);
de->de_entry_key.on_disk_key.k_objectid = le32_to_cpu (de->de_ih->ih_key.k_objectid);
set_cpu_key_k_offset (&(de->de_entry_key), deh_offset (deh));
@@ -702,11 +702,14 @@ static int reiserfs_rmdir (struct inode
struct inode * inode;
int windex ;
struct reiserfs_transaction_handle th ;
- int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3;
+ int jbegin_count;
INITIALIZE_PATH (path);
struct reiserfs_dir_entry de;
+ /* we will be doing 2 balancings and update 2 stat data */
+ jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2;
+
journal_begin(&th, dir->i_sb, jbegin_count) ;
windex = push_journal_writer("reiserfs_rmdir") ;
+ /* prevent empty directory from getting lost */
+ add_save_link (&th, inode, 0/* not truncate */);
+
pop_journal_writer(windex) ;
journal_end(&th, dir->i_sb, jbegin_count) ;
reiserfs_check_path(&path) ;
@@ -781,7 +787,13 @@ static int reiserfs_unlink (struct inode
INITIALIZE_PATH (path);
int windex ;
struct reiserfs_transaction_handle th ;
- int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3;
+ int jbegin_count;
+
+ inode = dentry->d_inode;
+
+ /* in this transaction we can be doing at max two balancings and update
+ two stat datas */
+ jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2;
+ if (!inode->i_nlink)
+ /* prevent file from getting lost */
+ add_save_link (&th, inode, 0/* not truncate */);
+
pop_journal_writer(windex) ;
journal_end(&th, dir->i_sb, jbegin_count) ;
reiserfs_check_path(&path) ;
@@ -1032,8 +1047,13 @@ static int reiserfs_rename (struct inode
struct inode * old_inode, * new_inode;
int windex ;
struct reiserfs_transaction_handle th ;
- int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3;
+ int jbegin_count ;
+
+ /* two balancings: old name removal, new name insertion or "save" link,
+ stat data updates: old directory and new directory and maybe block
+ containing ".." of renamed directory */
+ jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 3;
old_inode = old_dentry->d_inode;
new_inode = new_dentry->d_inode;
@@ -1176,29 +1196,25 @@ static int reiserfs_rename (struct inode
if (new_inode) {
// adjust link number of the victim
if (S_ISDIR(new_inode->i_mode)) {
- DEC_DIR_INODE_NLINK(new_inode)
+ new_inode->i_nlink = 0;
} else {
- new_inode->i_nlink--;
+ new_inode->i_nlink--;
}
new_inode->i_ctime = CURRENT_TIME;
}
if (S_ISDIR(old_inode->i_mode)) {
- //if (dot_dot_de.de_bh) {
- // adjust ".." of renamed directory
+ // adjust ".." of renamed directory
set_ino_in_dir_entry (&dot_dot_de, INODE_PKEY (new_dir));
journal_mark_dirty (&th, new_dir->i_sb, dot_dot_de.de_bh);
-
- DEC_DIR_INODE_NLINK(old_dir)
- if (new_inode) {
- if (S_ISDIR(new_inode->i_mode)) {
- DEC_DIR_INODE_NLINK(new_inode)
- } else {
- new_inode->i_nlink--;
- }
- } else {
- INC_DIR_INODE_NLINK(new_dir)
- }
+
+ if (!new_inode)
+ /* there (in new_dir) was no directory, so it got new link
+ (".." of renamed directory) */
+ INC_DIR_INODE_NLINK(new_dir);
+
+ /* old directory lost one link - ".. " of renamed directory */
+ DEC_DIR_INODE_NLINK(old_dir);
}
// looks like in 2.3.99pre3 brelse is atomic. so we can use pathrelse
@@ -1216,13 +1232,19 @@ static int reiserfs_rename (struct inode
reiserfs_update_sd (&th, old_dir);
reiserfs_update_sd (&th, new_dir);
- if (new_inode)
+
+ if (new_inode) {
+ if (new_inode->i_nlink == 0)
+ add_save_link (&th, new_inode, 0/* not truncate */);
reiserfs_update_sd (&th, new_inode);
+ }
// find out version of the key
to->version = le_key_version (from);
- if (to->version == ITEM_VERSION_1) {
+ if (to->version == KEY_FORMAT_3_5) {
to->on_disk_key.u.k_offset_v1.k_offset = le32_to_cpu (from->u.k_offset_v1.k_offset);
to->on_disk_key.u.k_offset_v1.k_uniqueness = le32_to_cpu (from->u.k_offset_v1.k_uniqueness);
} else {
@@ -727,7 +727,11 @@ int search_by_key (struct super_block *
continue;
}
- RFALSE( ! key_in_buffer(p_s_search_path, p_s_key, p_s_sb),
+ /* only check that the key is in the buffer if p_s_key is not
+ equal to the MAX_KEY. Latter case is only possible in
+ "finish_unfinished()" processing during mount. */
+ RFALSE( COMP_KEYS( &MAX_KEY, p_s_key ) &&
+ ! key_in_buffer(p_s_search_path, p_s_key, p_s_sb),
"PAP-5130: key is not in the buffer");
#ifdef CONFIG_REISERFS_CHECK
if ( cur_tb ) {
@@ -917,7 +921,7 @@ static inline int prepare_for_direct_ite
}
// new file gets truncated
- if (inode_items_version (inode) == ITEM_VERSION_2) {
+ if (get_inode_item_key_version (inode) == KEY_FORMAT_3_6) {
//
round_len = ROUND_UP (new_file_length);
/* this was n_new_file_length < le_ih ... */
@@ -1314,8 +1318,8 @@ int reiserfs_delete_item (struct reiserf
/* this deletes item which never gets split */
-static void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th,
- struct key * key)
+void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th,
+ struct key * key)
{
struct tree_balance tb;
INITIALIZE_PATH (path);
@@ -1408,7 +1412,7 @@ static int maybe_indirect_to_direct (str
*/
if (atomic_read(&p_s_inode->i_count) > 1 ||
!tail_has_to_be_packed (p_s_inode) ||
- !page || p_s_inode->u.reiserfs_i.nopack) {
+ !page || (p_s_inode->u.reiserfs_i.i_flags & i_nopack_mask)) {
// leave tail in an unformatted node
*p_c_mode = M_SKIP_BALANCING;
cut_bytes = n_block_size - (n_new_file_size & (n_block_size - 1));
@@ -1610,7 +1614,7 @@ int reiserfs_cut_from_item (struct reise
** be flushed before the transaction commits, so we don't need to
** deal with it here.
*/
- p_s_inode->u.reiserfs_i.i_pack_on_close = 0 ;
+ p_s_inode->u.reiserfs_i.i_flags &= ~i_pack_on_close_mask;
}
return n_ret_value;
}
@@ -1619,14 +1623,14 @@ int reiserfs_cut_from_item (struct reise
static void truncate_directory (struct reiserfs_transaction_handle *th, struct inode * inode)
{
if (inode->i_nlink)
- reiserfs_warning ("vs-5655: truncate_directory: link count != 0");
+ reiserfs_warning ("vs-5655: truncate_directory: link count != 0\n");
/* Set direct item header to insert. */
- make_le_item_head (&s_ih, 0, inode_items_version (p_s_inode), pos1 + 1,
+ make_le_item_head (&s_ih, 0, get_inode_item_key_version (p_s_inode), pos1 + 1,
TYPE_DIRECT, round_tail_len, 0xffff/*ih_free_space*/);
/* we want a pointer to the first byte of the tail in the page.
Only in linux.patched/include/linux: modules
diff -rup -X dontdiff linux/include/linux/reiserfs_fs.h linux.patched/include/linux/reiserfs_fs.h
--- linux/include/linux/reiserfs_fs.h Wed Nov 21 15:23:20 2001
+++ linux.patched/include/linux/reiserfs_fs.h Wed Nov 21 15:34:18 2001
@@ -144,10 +144,35 @@ struct unfm_nodeinfo {
unsigned short unfm_freespace;
};
-// this says about version of all items (but stat data) the object
-// consists of
-#define inode_items_version(inode) ((inode)->u.reiserfs_i.i_version)
+/* there are two formats of keys: 3.5 and 3.6
+ */
+#define KEY_FORMAT_3_5 0
+#define KEY_FORMAT_3_6 1
+
+/* there are two stat datas */
+#define STAT_DATA_V1 0
+#define STAT_DATA_V2 1
+
+/** this says about version of key of all items (but stat data) the
+ object consists of */
+#define get_inode_item_key_version( inode ) \
+ (((inode)->u.reiserfs_i.i_flags & i_item_key_version_mask) ? KEY_FORMAT_3_6 : KEY_FORMAT_3_5)
+
+#define set_inode_item_key_version( inode, version ) \
+ ({ if((version)==KEY_FORMAT_3_6) \
+ (inode)->u.reiserfs_i.i_flags |= i_item_key_version_mask; \
+ else \
+ (inode)->u.reiserfs_i.i_flags &= ~i_item_key_version_mask; })
+
+#define get_inode_sd_version(inode) \
+ (((inode)->u.reiserfs_i.i_flags & i_stat_data_version_mask) ? STAT_DATA_V2 : STAT_DATA_V1)
+
+#define set_inode_sd_version(inode, version) \
+ ({ if((version)==STAT_DATA_V2) \
+ (inode)->u.reiserfs_i.i_flags |= i_stat_data_version_mask; \
+ else \
+ (inode)->u.reiserfs_i.i_flags &= ~i_stat_data_version_mask; })
/* This is an aggressive tail suppression policy, I am hoping it
improves our benchmarks. The principle behind it is that percentage
@@ -186,18 +211,6 @@ struct unfm_nodeinfo {
/***************************************************************************/
//
-// we do support for old format of reiserfs: the problem is to
-// distinuquish keys with 32 bit offset and keys with 60 bit ones. On
-// leaf level we use ih_version of struct item_head (was
-// ih_reserved). For all old items it is set to 0
-// (ITEM_VERSION_1). For new items it is ITEM_VERSION_2. On internal
-// levels we have to know version of item key belongs to.
-//
-#define ITEM_VERSION_1 0
-#define ITEM_VERSION_2 1
-
-
-//
// directories use this key as well as old files
//
struct offset_v1 {
@@ -364,8 +377,8 @@ struct item_head
+/** bitmasks for i_flags field in reiserfs-specific part of inode */
+typedef enum {
+ /** this says what format of key do all items (but stat data) of
+ an object have. If this is set, that format is 3.6 otherwise
+ - 3.5 */
+ i_item_key_version_mask = 0x0001,
+ /** If this is unset, object has 3.5 stat data, otherwise, it has
+ 3.6 stat data with 64bit size, 32bit nlink etc. */
+ i_stat_data_version_mask = 0x0002,
+ /** file might need tail packing on close */
+ i_pack_on_close_mask = 0x0004,
+ /** don't pack tail of file */
+ i_nopack_mask = 0x0008,
+ /** If those is set, "safe link" was created for this file during
+ truncate or unlink. Safe link is used to avoid leakage of disk
+ space on crash with some files open, but unlinked. */
+ i_link_saved_unlink_mask = 0x0010,
+ i_link_saved_truncate_mask = 0x0020
+} reiserfs_inode_flags;
+
+
struct reiserfs_inode_info {
- __u32 i_key [4];/* key is still 4 32 bit integers */
+ __u32 i_key [4];/* key is still 4 32 bit integers */
- /* this comment will be totally
- cryptic to readers not familiar
- with 3.5/3.6 format conversion, and
- it does not consider that that 3.6
- might not be the last version */
- int i_version; // this says whether file is old or new
-
- int i_pack_on_close ; // file might need tail packing on close
-
- __u32 i_first_direct_byte; // offset of first byte stored in direct item.
-
- /* My guess is this contains the first
- unused block of a sequence of
- blocks plus the length of the
- sequence, which I think is always
- at least two at the time of the
- preallocation. I really prefer
- allocate on flush conceptually.....
-
- You know, it really annoys me when
- code is this badly commented that I
- have to guess what it does.
- Neither I nor anyone else has time
- for guessing what your
- datastructures mean. -Hans */
- //For preallocation
- int i_prealloc_block;
- int i_prealloc_count;
- struct list_head i_prealloc_list; /* per-transaction list of inodes which
- * have preallocated blocks */
- /* I regret that you think the below
- is a comment you should make.... -Hans */
- //nopack-attribute
- int nopack;
+ /** transient inode flags that are never stored on disk. Bitmasks
+ for this field are defined above. */
+ __u32 i_flags;
+
+ __u32 i_first_direct_byte; // offset of first byte stored in direct item.
+
+ int i_prealloc_block; /* first unused block of a sequence of unused blocks */
+ int i_prealloc_count; /* length of that sequence */
+ struct list_head i_prealloc_list; /* per-transaction list of inodes which
+ * have preallocated blocks */
- /* we use these for fsync or O_SYNC to decide which transaction needs
- ** to be committed in order for this inode to be properly flushed
- */
- unsigned long i_trans_id ;
- unsigned long i_trans_index ;
+ /* we use these for fsync or O_SYNC to decide which transaction
+ ** needs to be committed in order for this inode to be properly
+ ** flushed */
+ unsigned long i_trans_id ;
+ unsigned long i_trans_index ;
};