reiser4progs: Handle unprepped items by fsck
PATCH 1/1 reiser4progs: Handle unprepped items by fsck
Hello everyone. This patch fixes the problem (segmentation fault) in fsck reported by Bringfried Stecklum and Jonáš Vidra:
http://marc.info/?l=reiserfs-devel&m=126936575206572&w=2
However, the source of the problem in the kernel (data loss by cryptcompress file plugin) is not yet eliminated.
Thanks,
Edward.
. Handle orphan "unprepped" clusters;
. Don't repair the value of cluster shift in ctail item
in all circumstances. If cluster shift is wrong, then remove the whole cluster.
--- plugin/object/ccreg40/ccreg40.c | 12 +- plugin/object/ccreg40/ccreg40.h | 9 + plugin/object/ccreg40/ccreg40_repair.c | 196 +++++++++++++++++---------------- 3 files changed, 121 insertions(+), 96 deletions(-)
plugin/object/ccreg40/ccreg40.h +8 -1
@@ -11,6 +11,12 @@#include "reiser4/plugin.h" #include "plugin/object/obj40/obj40.h" +#define MIN_VALID_CLUSTER_SHIFT (0xc) +#define MAX_VALID_CLUSTER_SHIFT (0x10) +#define UNPREPPED_CLUSTER_SHIFT (0xff) + +#define ccreg40_cloff (off, size) ((off) & ((size) - 1)) +#define ccreg40_clstart (off, size) ((off) & ~((size) - 1))#define ccreg40_clnext (off, size) (ccreg40_clstart(off, size) + (size))
@@ -22,7 +28,8 @@ extern errno_t ccreg40_check_struct(reisplace_func_t func, void *data, uint8_t mode); -extern uint32_t ccreg40_get_cluster_size (reiser4_place_t *place); +extern errno_t ccreg40_get_cluster_shift (reiser4_place_t *place, +uint8_t *shift);extern errno_t ccreg40_set_cluster_size (reiser4_place_t *place,uint32_t cluster);
plugin/object/ccreg40/ccreg40_repair.c +106 -90
296 lines not on this page · raw message
plugin/object/ccreg40/ccreg40.c +7 -5
@@ -8,7 +8,7 @@#include "ccreg40.h" #include "plugin/object/obj40/obj40_repair.h" -uint32_t ccreg40_get_cluster_size (reiser4_place_t *place) { +errno_t ccreg40_get_cluster_shift (reiser4_place_t *place,uint8_t *shift) {trans_hint_t hint;ctail_hint_t chint;
@@ -17,10 +17,12 @@ uint32_t ccreg40_get_cluster_size(reiser hint.specific = &chint; hint.count =1 ; -if (objcall (place, object->fetch_units, &hint) !=1 ) -return MAX_UINT32 ; - -return 1 << chint.shift; +if (objcall (place, object->fetch_units, &hint) !=1 ) { +aal_error ("Can not extract cluster shift." ); +return -EINVAL ; + } + *shift = chint.shift; +return 0 ; }errno_t ccreg40_set_cluster_size (reiser4_place_t *place,uint32_t cluster) {
Re: search_one_bitmap_forward oops
In reply to a message not in the archiveQuoted 23 lines · Bringfried Stecklum
Quoted 22 lines · Edward Shishkin
Quoted 21 lines · Bringfried Stecklum
Quoted 19 lines · Edward Shishkin
Quoted 11 lines · Bringfried Stecklum
Quoted 10 lines · Edward Shishkin
Quoted 8 lines · Bringfried Stecklum
Dear Edward,
thanks for the reply. Since I contacted you again concerning this bug,
my system is going mad because of it. I didn't change anything concerning the kernel but even just after login and idling, the bug happens. I'd like to stay with Reiser4. But right now it is getting really difficult.Quoted 3 lines
Quoted 1 line
Do you use the mount option "
dont_load_bitmap"?Yes, I used it so far for faster booting but switched it off now.
Please, don't use this mount option for now: it doesn't work properly. I'll try to reproduce and fix it at leisure.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Looks like, up'n running now for half an hour. Normally, I prefer to hibernate between sessions and thus boot rarely, the longer boot time is no obstacle. Good luck with fixing the issue.
It looks like missing bitmap is not uploaded somewhere..
But it used to work quite some time...
It seems I have found the bug.
The problem arises when we get to the /* race: ...*/ point (see the attached patch). This is not an error path, nevertheless we release all bitmaps and set zeroes to bnode fields. Welcome to the Oops...
Everyone, who experienced problems with on-demand bitmap loading
in reiser4 (the mount option "dont_load_bitmap"), please, try the attached patch.
Thanks,
Edward.
fs/reiser4/plugin/space/bitmap.c +35 -37
@@ -830,45 +830,43 @@ static int load_and_lock_bnode(struct bi } ret =prepare_bnode (bnode, &cjnode, &wjnode); -if (ret ==0 ) { -mutex_lock (&bnode->mutex); +if (ret) +return ret; -if (!atomic_read (&bnode->loaded)) { -assert ("nikita-2822" , cjnode !=NULL ); -assert ("nikita-2823" , wjnode !=NULL ); -assert ("nikita-2824" ,jnode_is_loaded (cjnode)); -assert ("nikita-2825" ,jnode_is_loaded (wjnode)); - - bnode->wjnode = wjnode; - bnode->cjnode = cjnode; - - ret =check_struct_bnode (bnode, current_blocksize); -if (!ret) { - cjnode = wjnode =NULL ; -atomic_set (&bnode->loaded,1 ); -/* working bitmap is initialized by on-disk -* commit bitmap. This should be performed -* under mutex. */ -memcpy (bnode_working_data (bnode), -bnode_commit_data (bnode), -bmap_size (current_blocksize)); - }else -mutex_unlock (&bnode->mutex); - }else -/* race: someone already loaded bitmap while we were -* busy initializing data. */ -check_bnode_loaded (bnode); - } - -if (wjnode !=NULL ) { -release (wjnode); - bnode->wjnode =NULL ; - } -if (cjnode !=NULL ) { -release (cjnode); - bnode->cjnode =NULL ; - } +mutex_lock (&bnode->mutex); +if (!atomic_read (&bnode->loaded)) { +assert ("nikita-2822" , cjnode !=NULL ); +assert ("nikita-2823" , wjnode !=NULL ); +assert ("nikita-2824" ,jnode_is_loaded (cjnode)); +assert ("nikita-2825" ,jnode_is_loaded (wjnode)); + + bnode->wjnode = wjnode; + bnode->cjnode = cjnode; + + ret =check_struct_bnode (bnode, current_blocksize); +if (unlikely (ret !=0 )) + goto error; + +atomic_set (&bnode->loaded,1 ); +/* working bitmap is initialized by on-disk +* commit bitmap. This should be performed +* under mutex. */ +memcpy (bnode_working_data (bnode), +bnode_commit_data (bnode), +bmap_size (current_blocksize)); + }else +/* race: someone already loaded bitmap +* while we were busy initializing data. */ +check_bnode_loaded (bnode); +return 0 ; + + error: +release (wjnode); +release (cjnode); + bnode->wjnode =NULL ; + bnode->cjnode =NULL ; +mutex_unlock (&bnode->mutex);return ret; }