Commit 1e559269 authored by Andrew Morton's avatar Andrew Morton Committed by David Mosberger

[PATCH] reiserfs support for blocksizes other than 4096 bytes

From: Oleg Drokin <green@namesys.com>

This patch allows reiserfs to support blocksizes from 1024 bytes and up to
PAGE_CACHE_SIZE.  Also it fixes two glitches that prevent reiserfs from
working correctly in case if PAGE_CACHE_SIZE is bigger than blocksize.

Originally this patch was created by Edward Shushkin and Vladimir Saveliev,
and then it was adapted to modern 2.4 and 2.5 by me.

Also people should be aware that 1024 bytes blocksize is not very good thing
as tree grows very fast.  mkreiserfs is able to create filesystems with
different blocksizes for quite a while already (-b switch).
parent b743d13b
...@@ -736,6 +736,7 @@ int reiserfs_prepare_file_region_for_write( ...@@ -736,6 +736,7 @@ int reiserfs_prepare_file_region_for_write(
struct buffer_head *itembuf=NULL; // Buffer head that contains items that we are going to deal with struct buffer_head *itembuf=NULL; // Buffer head that contains items that we are going to deal with
INITIALIZE_PATH(path); // path to item, that we are going to deal with. INITIALIZE_PATH(path); // path to item, that we are going to deal with.
__u32 * item=0; // pointer to item we are going to deal with __u32 * item=0; // pointer to item we are going to deal with
int item_pos=-1; /* Position in indirect item */
if ( num_pages < 1 ) { if ( num_pages < 1 ) {
...@@ -807,7 +808,6 @@ int reiserfs_prepare_file_region_for_write( ...@@ -807,7 +808,6 @@ int reiserfs_prepare_file_region_for_write(
reiserfs_write_lock(inode->i_sb); // We need that for at least search_by_key() reiserfs_write_lock(inode->i_sb); // We need that for at least search_by_key()
for ( i = 0; i < num_pages ; i++ ) { for ( i = 0; i < num_pages ; i++ ) {
int item_pos=-1; /* Position in indirect item */
head = page_buffers(prepared_pages[i]); head = page_buffers(prepared_pages[i]);
/* For each buffer in the page */ /* For each buffer in the page */
......
...@@ -2109,11 +2109,13 @@ static int reiserfs_write_full_page(struct page *page, struct writeback_control ...@@ -2109,11 +2109,13 @@ static int reiserfs_write_full_page(struct page *page, struct writeback_control
* someone else could have locked them and sent them down the * someone else could have locked them and sent them down the
* pipe without locking the page * pipe without locking the page
*/ */
bh = head ;
do { do {
if (!buffer_uptodate(bh)) { if (!buffer_uptodate(bh)) {
partial = 1; partial = 1;
break; break;
} }
bh = bh->b_this_page;
} while(bh != head); } while(bh != head);
if (!partial) if (!partial)
SetPageUptodate(page); SetPageUptodate(page);
......
This diff is collapsed.
...@@ -546,12 +546,13 @@ static int print_desc_block (struct buffer_head * bh) ...@@ -546,12 +546,13 @@ static int print_desc_block (struct buffer_head * bh)
{ {
struct reiserfs_journal_desc * desc; struct reiserfs_journal_desc * desc;
desc = (struct reiserfs_journal_desc *)(bh->b_data); if (memcmp(get_journal_desc_magic (bh), JOURNAL_DESC_MAGIC, 8))
if (memcmp(desc->j_magic, JOURNAL_DESC_MAGIC, 8))
return 1; return 1;
desc = (struct reiserfs_journal_desc *)(bh->b_data);
printk ("Desc block %llu (j_trans_id %d, j_mount_id %d, j_len %d)", printk ("Desc block %llu (j_trans_id %d, j_mount_id %d, j_len %d)",
(unsigned long long)bh->b_blocknr, desc->j_trans_id, desc->j_mount_id, desc->j_len); (unsigned long long)bh->b_blocknr, get_desc_trans_id (desc), get_desc_mount_id (desc),
get_desc_trans_len (desc));
return 0; return 0;
} }
......
...@@ -23,9 +23,6 @@ ...@@ -23,9 +23,6 @@
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/vfs.h> #include <linux/vfs.h>
#define REISERFS_OLD_BLOCKSIZE 4096
#define REISERFS_SUPER_MAGIC_STRING_OFFSET_NJ 20
static struct file_system_type reiserfs_fs_type; static struct file_system_type reiserfs_fs_type;
const char reiserfs_3_5_magic_string[] = REISERFS_SUPER_MAGIC_STRING; const char reiserfs_3_5_magic_string[] = REISERFS_SUPER_MAGIC_STRING;
......
...@@ -1631,29 +1631,43 @@ struct reiserfs_iget_args { ...@@ -1631,29 +1631,43 @@ struct reiserfs_iget_args {
/***************************************************************************/ /***************************************************************************/
/*#ifdef __KERNEL__*/ /*#ifdef __KERNEL__*/
#define get_journal_desc_magic(bh) (bh->b_data + bh->b_size - 12)
/* journal.c see journal.c for all the comments here */ #define journal_trans_half(blocksize) \
((blocksize - sizeof (struct reiserfs_journal_desc) + sizeof (__u32) - 12) / sizeof (__u32))
#define JOURNAL_TRANS_HALF 1018 /* must be correct to keep the desc and commit structs at 4k */
/* journal.c see journal.c for all the comments here */
/* first block written in a commit. */ /* first block written in a commit. */
struct reiserfs_journal_desc { struct reiserfs_journal_desc {
__u32 j_trans_id ; /* id of commit */ __u32 j_trans_id ; /* id of commit */
__u32 j_len ; /* length of commit. len +1 is the commit block */ __u32 j_len ; /* length of commit. len +1 is the commit block */
__u32 j_mount_id ; /* mount id of this trans*/ __u32 j_mount_id ; /* mount id of this trans*/
__u32 j_realblock[JOURNAL_TRANS_HALF] ; /* real locations for each block */ __u32 j_realblock[1] ; /* real locations for each block */
char j_magic[12] ;
} ; } ;
#define get_desc_trans_id(d) le32_to_cpu((d)->j_trans_id)
#define get_desc_trans_len(d) le32_to_cpu((d)->j_len)
#define get_desc_mount_id(d) le32_to_cpu((d)->j_mount_id)
#define set_desc_trans_id(d,val) do { (d)->j_trans_id = cpu_to_le32 (val); } while (0)
#define set_desc_trans_len(d,val) do { (d)->j_len = cpu_to_le32 (val); } while (0)
#define set_desc_mount_id(d,val) do { (d)->j_mount_id = cpu_to_le32 (val); } while (0)
/* last block written in a commit */ /* last block written in a commit */
struct reiserfs_journal_commit { struct reiserfs_journal_commit {
__u32 j_trans_id ; /* must match j_trans_id from the desc block */ __u32 j_trans_id ; /* must match j_trans_id from the desc block */
__u32 j_len ; /* ditto */ __u32 j_len ; /* ditto */
__u32 j_realblock[JOURNAL_TRANS_HALF] ; /* real locations for each block */ __u32 j_realblock[1] ; /* real locations for each block */
char j_digest[16] ; /* md5 sum of all the blocks involved, including desc and commit. not used, kill it */
} ; } ;
#define get_commit_trans_id(c) le32_to_cpu((c)->j_trans_id)
#define get_commit_trans_len(c) le32_to_cpu((c)->j_len)
#define get_commit_mount_id(c) le32_to_cpu((c)->j_mount_id)
#define set_commit_trans_id(c,val) do { (c)->j_trans_id = cpu_to_le32 (val); } while (0)
#define set_commit_trans_len(c,val) do { (c)->j_len = cpu_to_le32 (val); } while (0)
/* this header block gets written whenever a transaction is considered fully flushed, and is more recent than the /* this header block gets written whenever a transaction is considered fully flushed, and is more recent than the
** last fully flushed transaction. fully flushed means all the log blocks and all the real blocks are on disk, ** last fully flushed transaction. fully flushed means all the log blocks and all the real blocks are on disk,
** and this transaction does not need to be replayed. ** and this transaction does not need to be replayed.
......
...@@ -253,6 +253,8 @@ struct reiserfs_journal { ...@@ -253,6 +253,8 @@ struct reiserfs_journal {
struct reiserfs_journal_cnode *j_list_hash_table[JOURNAL_HASH_SIZE] ; /* hash table for all the real buffer heads in all struct reiserfs_journal_cnode *j_list_hash_table[JOURNAL_HASH_SIZE] ; /* hash table for all the real buffer heads in all
the transactions */ the transactions */
struct list_head j_prealloc_list; /* list of inodes which have preallocated blocks */ struct list_head j_prealloc_list; /* list of inodes which have preallocated blocks */
unsigned long j_max_trans_size ;
unsigned long j_max_batch_size ;
}; };
#define JOURNAL_DESC_MAGIC "ReIsErLB" /* ick. magic string to find desc blocks in the journal */ #define JOURNAL_DESC_MAGIC "ReIsErLB" /* ick. magic string to find desc blocks in the journal */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment