Convert to new style set/clear funcs
PATCH 1/1 Convert to new style set/clear funcs
The following is a small patch that pushes ocfs just a little bit further towards a working 2.6 port.
The mark_buffer_XXX(bh, bool) functions have been replaced with set_buffer_XXX(bh)/clear_buffer_XXX(bh)/buffer_XXX(bh) functions in the new linux/buffer_head.h
This patch defines the 2.6 function in a 2.4 build, and then converts all the 2.4 calls to 2.6 calls. I did this to reduce the amount of #ifdef/#endif stuff in the *.c files.
--rusty
super.c +1 -5
@@ -707,7 +707,7 @@OCFS_BH_PUT_DATA (bh);lock_buffer (bh); -mark_buffer_uptodate (bh, false); +clear_buffer_uptodate (bh);unlock_buffer (bh);brelse (bh);
@@ -812,11 +812,7 @@lock_buffer (bhs[i]);if (!buffer_dirty (bhs[i])) -#ifdef LINUX_2_5 clear_buffer_uptodate (bhs[i]); -#else -mark_buffer_uptodate (bhs[i], false); -#endif unlock_buffer (bhs[i]); }
io.c +1 -17
@@ -265,12 +265,8 @@ }lock_buffer (bh); - -#ifdef LINUX_2_5 set_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, true); -#endif +/* remove from dirty list before I/O. */ mark_buffer_clean (bh);
@@ -418,11 +414,7 @@ }lock_buffer (bh); -#ifdef LINUX_2_5 clear_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, false); -#endif bh->b_end_io = ocfs_end_buffer_io_sync;submit_bh (READ , bh);continue ;
@@ -547,11 +539,7 @@lock_buffer (bh); -#ifdef LINUX_2_5 set_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, true); -#endif /* remove from dirty list before I/O. */ mark_buffer_clean (bh);
@@ -699,11 +687,7 @@ }lock_buffer (bh); -#ifdef LINUX_2_5 clear_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, false); -#endif bh->b_end_io = ocfs_end_buffer_io_sync;submit_bh (READ , bh);continue ;
journal.c +2 -6
@@ -511,12 +511,8 @@* gets written to disk inadvertantly by someone * else. */ -#ifdef LINUX_2_5 clear_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, false); -#endif -clear_bit (BH_Dirty, &bh->b_state); +clear_buffer_dirty (bh);unlock_buffer (bh);/* journal_forget will bforget the buffers for us too. */
@@ -1930,7 +1926,7 @@BUFFER_TRACE (bh,"marking dirty" );mark_buffer_dirty (bh);BUFFER_TRACE (bh,"marking uptodate" ); -mark_buffer_uptodate (bh,1 ); +set_buffer_uptodate (bh);brelse (bh); }
util.c +4 -1
@@ -403,7 +403,10 @@if (!uptodate)LOG_ERROR_STATUS (-EIO ); -mark_buffer_uptodate (bh, uptodate); +if (uptodate) +set_buffer_uptodate (bh); +else +clear_buffer_uptodate (bh);unlock_buffer (bh);// LOG_EXIT();
dir.c +2 -2
@@ -806,7 +806,7 @@ freeOffset =0 ; } -mark_buffer_uptodate (bhs[freeOffset+1 ], true); +set_buffer_uptodate (bhs[freeOffset+1 ]); status =ocfs_journal_access (handle, bhs[freeOffset+1 ],OCFS_JOURNAL_ACCESS_WRITE );if (status <0 ) {
@@ -1248,7 +1248,7 @@ newbhs[i] =getblk (OCFS_GET_BLOCKDEV (osb->sb), blk++, osb->sb->s_blocksize); -mark_buffer_uptodate (newbhs[i], true); +set_buffer_uptodate (newbhs[i]);/* clear all 128k, all garbage currently */ status =ocfs_journal_access (handle, newbhs[i],OCFS_JOURNAL_ACCESS_WRITE );
oin.c +1 -1
@@ -576,7 +576,7 @@if (hdr_bh) {lock_buffer (hdr_bh); -mark_buffer_uptodate (hdr_bh, false); +clear_buffer_uptodate (hdr_bh);unlock_buffer (hdr_bh);brelse (hdr_bh); }
inc/io.h +33 -3
@@ -50,11 +50,41 @@#define OCFS_NONCACHED (osb,off) ((off) < (osb)->vol_layout.data_start_off)#define BH_Modified 18 -#define buffer_modified (bh) __buffer_state((bh),Modified) -#define set_buffer_modified (bh) set_bit(BH_Modified, &(bh)->b_state); -#define clear_buffer_modified (bh) clear_bit(BH_Modified, &(bh)->b_state); +#if LINUX_VERSION_CODE >KERNEL_VERSION (2 ,5 ,0 ) +/* +* BUFFER_FNS is the new marcro magic intruduced in 2.5.x kernel for defining +* set_buffer_XXX, clear_buffer_XXX, and buffer_XXX functions +*/ +BUFFER_FNS(Modified, modified) +#else /* 2.4.x kernel */ + +/* +* Copied right out of the 2.6.2 kernel's buffer_head.h: +* macro tricks to expand the set_buffer_foo(), clear_buffer_foo() +* and buffer_foo() functions. +*/ +#define BUFFER_FNS (bit, name) \ +static inline void set_buffer_##name(struct buffer_head *bh) \ +{ \ + set_bit(BH_##bit, &(bh)->b_state); \ +} \ +static inline void clear_buffer_##name(struct buffer_head *bh) \ +{ \ + clear_bit(BH_##bit, &(bh)->b_state); \ +} \ +static inline int buffer_##name(struct buffer_head *bh) \ +{ \ + return test_bit(BH_##bit, &(bh)->b_state); \ +} + +#undef buffer_uptodate +BUFFER_FNS(Uptodate, uptodate) +BUFFER_FNS(Modified, modified) + +#endif /* 2.4.x kernel */ +static inline void *OCFS_BH_GET_DATA_READ (struct buffer_head *bh) {unsigned char *kaddr;
namei.c +1 -1
@@ -425,7 +425,7 @@ dirbhs[i] =getblk (OCFS_GET_BLOCKDEV (osb->sb), blk++, osb->sb->s_blocksize); -mark_buffer_uptodate (dirbhs[i], true); +set_buffer_uptodate (dirbhs[i]); status =ocfs_journal_access (handle, dirbhs[i],OCFS_JOURNAL_ACCESS_WRITE );if (status <0 ) {
alloc.c +0 -8
@@ -673,11 +673,7 @@memset (buff,0 , osb->sect_size);/* TODO: Do we really need to do this? */ -#ifdef LINUX_2_5 set_buffer_uptodate (header_bhs[i]); -#else -mark_buffer_uptodate (header_bhs[i], true); -#endif OCFS_BH_PUT_DATA (header_bhs[i]); }
@@ -901,11 +897,7 @@ } buf =OCFS_BH_GET_DATA_WRITE (bhs[i]);/* write */ memset (buf,0 , osb->sect_size); -#ifdef LINUX_2_5 set_buffer_uptodate (bhs[i]); -#else -mark_buffer_uptodate (bhs[i], true); -#endif OCFS_BH_PUT_DATA (bhs[i]); }
PATCH 1/1 Convert to new style set/clear funcs
Quoted 10 lines · Rusty Lynch
The following is a small patch that pushes ocfs just a little bit further towards a working 2.6 port.
The
mark_buffer_XXX(bh, bool)functions have been replaced with set_buffer_XXX(bh)/clear_buffer_XXX(bh)/buffer_XXX(bh) functions in the newlinux/buffer_head.hThis patch defines the 2.6 function in a 2.4 build, and then converts all the 2.4 calls to 2.6 calls. I did this to reduce the amount of #ifdef/#endif stuff in the *.c files.
I must be getting tired... made a small mistake on the last patch
BTW, this is against version 27 from svn
--rusty
super.c +1 -5
@@ -707,7 +707,7 @@OCFS_BH_PUT_DATA (bh);lock_buffer (bh); -mark_buffer_uptodate (bh, false); +clear_buffer_uptodate (bh);unlock_buffer (bh);brelse (bh);
@@ -812,11 +812,7 @@lock_buffer (bhs[i]);if (!buffer_dirty (bhs[i])) -#ifdef LINUX_2_5 clear_buffer_uptodate (bhs[i]); -#else -mark_buffer_uptodate (bhs[i], false); -#endif unlock_buffer (bhs[i]); }
io.c +1 -17
@@ -265,12 +265,8 @@ }lock_buffer (bh); - -#ifdef LINUX_2_5 set_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, true); -#endif +/* remove from dirty list before I/O. */ mark_buffer_clean (bh);
@@ -418,11 +414,7 @@ }lock_buffer (bh); -#ifdef LINUX_2_5 clear_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, false); -#endif bh->b_end_io = ocfs_end_buffer_io_sync;submit_bh (READ , bh);continue ;
@@ -547,11 +539,7 @@lock_buffer (bh); -#ifdef LINUX_2_5 set_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, true); -#endif /* remove from dirty list before I/O. */ mark_buffer_clean (bh);
@@ -699,11 +687,7 @@ }lock_buffer (bh); -#ifdef LINUX_2_5 clear_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, false); -#endif bh->b_end_io = ocfs_end_buffer_io_sync;submit_bh (READ , bh);continue ;
journal.c +2 -6
@@ -511,12 +511,8 @@* gets written to disk inadvertantly by someone * else. */ -#ifdef LINUX_2_5 clear_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, false); -#endif -clear_bit (BH_Dirty, &bh->b_state); +clear_buffer_dirty (bh);unlock_buffer (bh);/* journal_forget will bforget the buffers for us too. */
@@ -1930,7 +1926,7 @@BUFFER_TRACE (bh,"marking dirty" );mark_buffer_dirty (bh);BUFFER_TRACE (bh,"marking uptodate" ); -mark_buffer_uptodate (bh,1 ); +set_buffer_uptodate (bh);brelse (bh); }
util.c +4 -1
@@ -403,7 +403,10 @@if (!uptodate)LOG_ERROR_STATUS (-EIO ); -mark_buffer_uptodate (bh, uptodate); +if (uptodate) +set_buffer_uptodate (bh); +else +clear_buffer_uptodate (bh);unlock_buffer (bh);// LOG_EXIT();
dir.c +2 -2
@@ -806,7 +806,7 @@ freeOffset =0 ; } -mark_buffer_uptodate (bhs[freeOffset+1 ], true); +set_buffer_uptodate (bhs[freeOffset+1 ]); status =ocfs_journal_access (handle, bhs[freeOffset+1 ],OCFS_JOURNAL_ACCESS_WRITE );if (status <0 ) {
@@ -1248,7 +1248,7 @@ newbhs[i] =getblk (OCFS_GET_BLOCKDEV (osb->sb), blk++, osb->sb->s_blocksize); -mark_buffer_uptodate (newbhs[i], true); +set_buffer_uptodate (newbhs[i]);/* clear all 128k, all garbage currently */ status =ocfs_journal_access (handle, newbhs[i],OCFS_JOURNAL_ACCESS_WRITE );
oin.c +1 -1
@@ -576,7 +576,7 @@if (hdr_bh) {lock_buffer (hdr_bh); -mark_buffer_uptodate (hdr_bh, false); +clear_buffer_uptodate (hdr_bh);unlock_buffer (hdr_bh);brelse (hdr_bh); }
inc/io.h +35 -3
@@ -50,11 +50,43 @@#define OCFS_NONCACHED (osb,off) ((off) < (osb)->vol_layout.data_start_off)#define BH_Modified 18 -#define buffer_modified (bh) __buffer_state((bh),Modified) -#define set_buffer_modified (bh) set_bit(BH_Modified, &(bh)->b_state); -#define clear_buffer_modified (bh) clear_bit(BH_Modified, &(bh)->b_state); +#if LINUX_VERSION_CODE >KERNEL_VERSION (2 ,5 ,0 ) +/* +* BUFFER_FNS is the new marcro magic intruduced in 2.5.x kernel for defining +* set_buffer_XXX, clear_buffer_XXX, and buffer_XXX functions +*/ +BUFFER_FNS(Modified, modified) +#else /* 2.4.x kernel */ + +/* +* Copied right out of the 2.6.2 kernel's buffer_head.h: +* macro tricks to expand the set_buffer_foo(), clear_buffer_foo() +* and buffer_foo() functions. +*/ +#define BUFFER_FNS (bit, name) \ +static inline void set_buffer_##name(struct buffer_head *bh) \ +{ \ + set_bit(BH_##bit, &(bh)->b_state); \ +} \ +static inline void clear_buffer_##name(struct buffer_head *bh) \ +{ \ + clear_bit(BH_##bit, &(bh)->b_state); \ +} \ +static inline int buffer_##name(struct buffer_head *bh) \ +{ \ + return test_bit(BH_##bit, &(bh)->b_state); \ +} + +#undef buffer_uptodate +#undef buffer_dirty +BUFFER_FNS(Uptodate, uptodate) +BUFFER_FNS(Modified, modified) +BUFFER_FNS(Dirty, dirty) + +#endif /* 2.4.x kernel */ +static inline void *OCFS_BH_GET_DATA_READ (struct buffer_head *bh) {unsigned char *kaddr;
namei.c +1 -1
@@ -425,7 +425,7 @@ dirbhs[i] =getblk (OCFS_GET_BLOCKDEV (osb->sb), blk++, osb->sb->s_blocksize); -mark_buffer_uptodate (dirbhs[i], true); +set_buffer_uptodate (dirbhs[i]); status =ocfs_journal_access (handle, dirbhs[i],OCFS_JOURNAL_ACCESS_WRITE );if (status <0 ) {
alloc.c +0 -8
@@ -673,11 +673,7 @@memset (buff,0 , osb->sect_size);/* TODO: Do we really need to do this? */ -#ifdef LINUX_2_5 set_buffer_uptodate (header_bhs[i]); -#else -mark_buffer_uptodate (header_bhs[i], true); -#endif OCFS_BH_PUT_DATA (header_bhs[i]); }
@@ -901,11 +897,7 @@ } buf =OCFS_BH_GET_DATA_WRITE (bhs[i]);/* write */ memset (buf,0 , osb->sect_size); -#ifdef LINUX_2_5 set_buffer_uptodate (bhs[i]); -#else -mark_buffer_uptodate (bhs[i], true); -#endif OCFS_BH_PUT_DATA (bhs[i]); }
PATCH 1/1 Convert to new style set/clear funcs
Quoted 12 lines · Rusty Lynch
Quoted 10 lines · Rusty Lynch
The following is a small patch that pushes ocfs just a little bit further towards a working 2.6 port.
The
mark_buffer_XXX(bh, bool)functions have been replaced with set_buffer_XXX(bh)/clear_buffer_XXX(bh)/buffer_XXX(bh) functions in the newlinux/buffer_head.hThis patch defines the 2.6 function in a 2.4 build, and then converts all the 2.4 calls to 2.6 calls. I did this to reduce the amount of #ifdef/#endif stuff in the *.c files.
Quoted 5 lines
I must be getting tired... made a small mistake on the last patch
BTW, this is against version 27 from svn
--rusty
This looks good. Can you change it to look for kernels 2.6.0 and greater though? We really don't care about 2.5 kernels at this point :)
--Mark
Quoted 251 lines
Index:
src/super.c
===================================================================super.c +1
-5@@ -707,7 +707,7 @@OCFS_BH_PUT_DATA (bh);lock_buffer (bh); -mark_buffer_uptodate (bh, false); +clear_buffer_uptodate (bh);unlock_buffer (bh);brelse (bh);@@ -812,11 +812,7 @@lock_buffer (bhs[i]);if (!buffer_dirty (bhs[i])) -#ifdef LINUX_2_5 clear_buffer_uptodate (bhs[i]); -#else -mark_buffer_uptodate (bhs[i], false); -#endif unlock_buffer (bhs[i]); }Index:
src/io.c
===================================================================io.c +1
-17@@ -265,12 +265,8 @@ }lock_buffer (bh); - -#ifdef LINUX_2_5 set_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, true); -#endif +/* remove from dirty list before I/O. */ mark_buffer_clean (bh);@@ -418,11 +414,7 @@ }lock_buffer (bh); -#ifdef LINUX_2_5 clear_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, false); -#endif bh->b_end_io = ocfs_end_buffer_io_sync;submit_bh (READ , bh);continue ;@@ -547,11 +539,7 @@lock_buffer (bh); -#ifdef LINUX_2_5 set_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, true); -#endif /* remove from dirty list before I/O. */ mark_buffer_clean (bh);@@ -699,11 +687,7 @@ }lock_buffer (bh); -#ifdef LINUX_2_5 clear_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, false); -#endif bh->b_end_io = ocfs_end_buffer_io_sync;submit_bh (READ , bh);continue ;Index:
src/journal.c
===================================================================journal.c +2
-6@@ -511,12 +511,8 @@* gets written to disk inadvertantly by someone * else. */ -#ifdef LINUX_2_5 clear_buffer_uptodate (bh); -#else -mark_buffer_uptodate (bh, false); -#endif -clear_bit (BH_Dirty, &bh->b_state); +clear_buffer_dirty (bh);unlock_buffer (bh);/* journal_forget will bforget the buffers for us too. */ @@ -1930,7 +1926,7 @@BUFFER_TRACE (bh,"marking dirty" );mark_buffer_dirty (bh);BUFFER_TRACE (bh,"marking uptodate" ); -mark_buffer_uptodate (bh,1 ); +set_buffer_uptodate (bh);brelse (bh); }Index:
src/util.c
===================================================================util.c +4
-1@@ -403,7 +403,10 @@if (!uptodate)LOG_ERROR_STATUS (-EIO ); -mark_buffer_uptodate (bh, uptodate); +if (uptodate) +set_buffer_uptodate (bh); +else +clear_buffer_uptodate (bh);unlock_buffer (bh);// LOG_EXIT(); Index:
src/dir.c
===================================================================dir.c +2
-2@@ -806,7 +806,7 @@ freeOffset =0 ; } -mark_buffer_uptodate (bhs[freeOffset+1 ], true); +set_buffer_uptodate (bhs[freeOffset+1 ]); status =ocfs_journal_access (handle, bhs[freeOffset+1 ],OCFS_JOURNAL_ACCESS_WRITE );if (status <0 ) {@@ -1248,7 +1248,7 @@ newbhs[i] =getblk (OCFS_GET_BLOCKDEV (osb->sb), blk++, osb->sb->s_blocksize); -mark_buffer_uptodate (newbhs[i], true); +set_buffer_uptodate (newbhs[i]);/* clear all 128k, all garbage currently */ status =ocfs_journal_access (handle, newbhs[i],OCFS_JOURNAL_ACCESS_WRITE );Index:
src/oin.c
===================================================================oin.c +1
-1@@ -576,7 +576,7 @@if (hdr_bh) {lock_buffer (hdr_bh); -mark_buffer_uptodate (hdr_bh, false); +clear_buffer_uptodate (hdr_bh);unlock_buffer (hdr_bh);brelse (hdr_bh); }Index:
src/inc/io.h
===================================================================inc/io.h +35
-3@@ -50,11 +50,43 @@#define OCFS_NONCACHED (osb,off) ((off) < (osb)->vol_layout.data_start_off)#define BH_Modified 18 -#define buffer_modified (bh) __buffer_state((bh),Modified) -#define set_buffer_modified (bh) set_bit(BH_Modified, &(bh)->b_state); -#define clear_buffer_modified (bh) clear_bit(BH_Modified, &(bh)->b_state); +#if LINUX_VERSION_CODE >KERNEL_VERSION (2 ,5 ,0 ) +/* +* BUFFER_FNS is the new marcro magic intruduced in 2.5.x kernel for defining +* set_buffer_XXX, clear_buffer_XXX, and buffer_XXX functions +*/ +BUFFER_FNS(Modified, modified) +#else /* 2.4.x kernel */ + +/* +* Copied right out of the 2.6.2 kernel's buffer_head.h: +* macro tricks to expand the set_buffer_foo(), clear_buffer_foo() +* and buffer_foo() functions. +*/ +#define BUFFER_FNS (bit, name) \ +static inline void set_buffer_##name(struct buffer_head *bh) \ +{ \ + set_bit(BH_##bit, &(bh)->b_state); \ +} \ +static inline void clear_buffer_##name(struct buffer_head *bh) \ +{ \ + clear_bit(BH_##bit, &(bh)->b_state); \ +} \ +static inline int buffer_##name(struct buffer_head *bh) \ +{ \ + return test_bit(BH_##bit, &(bh)->b_state); \ +} + +#undef buffer_uptodate +#undef buffer_dirty +BUFFER_FNS(Uptodate, uptodate) +BUFFER_FNS(Modified, modified) +BUFFER_FNS(Dirty, dirty) + +#endif /* 2.4.x kernel */ +static inline void *OCFS_BH_GET_DATA_READ (struct buffer_head *bh) {unsigned char *kaddr;Index:
src/namei.c
===================================================================namei.c +1
-1@@ -425,7 +425,7 @@ dirbhs[i] =getblk (OCFS_GET_BLOCKDEV (osb->sb), blk++, osb->sb->s_blocksize); -mark_buffer_uptodate (dirbhs[i], true); +set_buffer_uptodate (dirbhs[i]); status =ocfs_journal_access (handle, dirbhs[i],OCFS_JOURNAL_ACCESS_WRITE );if (status <0 ) {Index:
src/alloc.c
===================================================================alloc.c +0
-8@@ -673,11 +673,7 @@memset (buff,0 , osb->sect_size);/* TODO: Do we really need to do this? */ -#ifdef LINUX_2_5 set_buffer_uptodate (header_bhs[i]); -#else -mark_buffer_uptodate (header_bhs[i], true); -#endif OCFS_BH_PUT_DATA (header_bhs[i]); }@@ -901,11 +897,7 @@ } buf =OCFS_BH_GET_DATA_WRITE (bhs[i]);/* write */ memset (buf,0 , osb->sect_size); -#ifdef LINUX_2_5 set_buffer_uptodate (bhs[i]); -#else -mark_buffer_uptodate (bhs[i], true); -#endif OCFS_BH_PUT_DATA (bhs[i]); }