コード例 #1
0
ファイル: stree.c プロジェクト: pemargo/asuswrt-merlin
/* returns 1 if buf looks like an internal node, 0 otherwise */
static int is_internal(char *buf, int blocksize, struct buffer_head *bh)
{
	struct block_head *blkh;
	int nr;
	int used_space;

	blkh = (struct block_head *)buf;
	nr = blkh_level(blkh);
	if (nr <= DISK_LEAF_NODE_LEVEL || nr > MAX_HEIGHT) {
		/* this level is not possible for internal nodes */
		reiserfs_warning(NULL, "reiserfs-5087",
				 "this should be caught earlier");
		return 0;
	}

	nr = blkh_nr_item(blkh);
	if (nr > (blocksize - BLKH_SIZE - DC_SIZE) / (KEY_SIZE + DC_SIZE)) {
		/* for internal which is not root we might check min number of keys */
		reiserfs_warning(NULL, "reiserfs-5088",
				 "number of key seems wrong: %z", bh);
		return 0;
	}

	used_space = BLKH_SIZE + KEY_SIZE * nr + DC_SIZE * (nr + 1);
	if (used_space != blocksize - blkh_free_space(blkh)) {
		reiserfs_warning(NULL, "reiserfs-5089",
				 "free space seems wrong: %z", bh);
		return 0;
	}
	// one may imagine much more checks
	return 1;
}
コード例 #2
0
ファイル: super.c プロジェクト: niubl/camera_project
// if root directory is empty - we set default - Yura's - hash and
// warn about it
// FIXME: we look for only one name in a directory. If tea and yura
// bith have the same value - we ask user to send report to the
// mailing list
__u32 find_hash_out (struct super_block * s)
{
    int retval;
    struct inode * inode;
    struct cpu_key key;
    INITIALIZE_PATH (path);
    struct reiserfs_dir_entry de;
    __u32 hash = DEFAULT_HASH;

    inode = s->s_root->d_inode;

    do { // Some serious "goto"-hater was there ;)
	u32 teahash, r5hash, yurahash;

	make_cpu_key (&key, inode, ~0, TYPE_DIRENTRY, 3);
	retval = search_by_entry_key (s, &key, &path, &de);
	if (retval == IO_ERROR) {
	    pathrelse (&path);
	    return UNSET_HASH ;
	}
	if (retval == NAME_NOT_FOUND)
	    de.de_entry_num --;
	set_de_name_and_namelen (&de);
	if (deh_offset( &(de.de_deh[de.de_entry_num]) ) == DOT_DOT_OFFSET) {
	    /* allow override in this case */
	    if (reiserfs_rupasov_hash(s)) {
		hash = YURA_HASH ;
	    }
	    reiserfs_warning("reiserfs: FS seems to be empty, autodetect "
	                     "is using the default hash\n");
	    break;
	}
	r5hash=GET_HASH_VALUE (r5_hash (de.de_name, de.de_namelen));
	teahash=GET_HASH_VALUE (keyed_hash (de.de_name, de.de_namelen));
	yurahash=GET_HASH_VALUE (yura_hash (de.de_name, de.de_namelen));
	if ( ( (teahash == r5hash) && (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash) ) ||
	     ( (teahash == yurahash) && (yurahash == GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])))) ) ||
	     ( (r5hash == yurahash) && (yurahash == GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])))) ) ) {
	    reiserfs_warning("reiserfs: Unable to automatically detect hash"
		"function for device %s\n"
		"please mount with -o hash={tea,rupasov,r5}\n", kdevname (s->s_dev));
	    hash = UNSET_HASH;
	    break;
	}
	if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == yurahash)
	    hash = YURA_HASH;
	else if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == teahash)
	    hash = TEA_HASH;
	else if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == r5hash)
	    hash = R5_HASH;
	else {
	    reiserfs_warning("reiserfs: Unrecognised hash function for "
			     "device %s\n", kdevname (s->s_dev));
	    hash = UNSET_HASH;
	}
    } while (0);

    pathrelse (&path);
    return hash;
}
コード例 #3
0
/* read super block and bitmaps. fixme: only 4k blocks, pre-journaled format
   is refused */
reiserfs_filsys_t reiserfs_open (char * filename, int flags, int *error, void * vp)
{
    reiserfs_filsys_t fs;
    struct buffer_head * bh;
    struct reiserfs_super_block * rs;
    int fd, i;
    
    fd = open (filename, flags | O_LARGEFILE);
    if (fd == -1) {
	if (error)
	    *error = errno;
	return 0;
    }

    fs = getmem (sizeof (*fs));
    fs->s_dev = fd;
    fs->s_vp = vp;
    asprintf (&fs->file_name, "%s", filename);

    /* reiserfs super block is either in 16-th or in 2-nd 4k block of the
       device */
    for (i = 16; i > 0; i -= 14) {
	bh = bread (fd, i, 4096);
	if (!bh) {
	    reiserfs_warning (stderr, "reiserfs_open: bread failed reading block %d\n", i);
	} else {
	    rs = (struct reiserfs_super_block *)bh->b_data;
	    
	    if (is_reiser2fs_magic_string (rs) || is_reiserfs_magic_string (rs))
		goto found;

	    /* reiserfs signature is not found at the i-th 4k block */
	    brelse (bh);
	}
    }

    reiserfs_warning (stderr, "reiserfs_open: neither new nor old reiserfs format "
		      "found on %s\n", filename);
    if (error)
	*error = 0;
    return fs;

 found:

    /* fixme: we could make some check to make sure that super block looks
       correctly */
    fs->s_version = is_reiser2fs_magic_string (rs) ? REISERFS_VERSION_2 :
	REISERFS_VERSION_1;
    fs->s_blocksize = rs_blocksize (rs);
    fs->s_hash_function = code2func (rs_hash (rs));
    SB_BUFFER_WITH_SB (fs) = bh;
    fs->s_rs = rs;
    fs->s_flags = flags; /* O_RDONLY or O_RDWR */
    fs->s_vp = vp;

    reiserfs_read_bitmap_blocks(fs);
	
    return fs;

}
コード例 #4
0
ファイル: prints.c プロジェクト: fgeraci/cs518-sched
/* this prints internal nodes (4 keys/items in line) (dc_number,
   dc_size)[k_dirid, k_objectid, k_offset, k_uniqueness](dc_number,
   dc_size)...*/
static int print_internal (struct buffer_head * bh, int first, int last)
{
    struct key * key;
    struct disk_child * dc;
    int i;
    int from, to;
    
    if (!B_IS_KEYS_LEVEL (bh))
	return 1;

    check_internal (bh);
    
    if (first == -1) {
	from = 0;
	to = B_NR_ITEMS (bh);
    } else {
	from = first;
	to = last < B_NR_ITEMS (bh) ? last : B_NR_ITEMS (bh);
    }

    reiserfs_warning ("INTERNAL NODE (%ld) contains %z\n",  bh->b_blocknr, bh);
    
    dc = B_N_CHILD (bh, from);
    reiserfs_warning ("PTR %d: %y ", from, dc);
    
    for (i = from, key = B_N_PDELIM_KEY (bh, from), dc ++; i < to; i ++, key ++, dc ++) {
	reiserfs_warning ("KEY %d: %k PTR %d: %y ", i, key, i + 1, dc);
	if (i && i % 4 == 0)
	    printk ("\n");
    }
    printk ("\n");
    return 0;
}
コード例 #5
0
ファイル: namei.c プロジェクト: FatSunHYS/OSCourseDesign
/* The function is NOT SCHEDULE-SAFE! */
int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
			struct path *path, struct reiserfs_dir_entry *de)
{
	int retval;

	retval = search_item(sb, key, path);
	switch (retval) {
	case ITEM_NOT_FOUND:
		if (!PATH_LAST_POSITION(path)) {
			reiserfs_warning(sb,
					 "vs-7000: search_by_entry_key: search_by_key returned item position == 0");
			pathrelse(path);
			return IO_ERROR;
		}
		PATH_LAST_POSITION(path)--;

	case ITEM_FOUND:
		break;

	case IO_ERROR:
		return retval;

	default:
		pathrelse(path);
		reiserfs_warning(sb,
				 "vs-7002: search_by_entry_key: no path to here");
		return IO_ERROR;
	}

	set_de_item_location(de, path);

#ifdef CONFIG_REISERFS_CHECK
	if (!is_direntry_le_ih(de->de_ih) ||
	    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);
	}
#endif				/* CONFIG_REISERFS_CHECK */

	/* binary search in directory item by third componen t of the
	   key. sets de->de_entry_num of de */
	retval = bin_search_in_dir_item(de, cpu_key_k_offset(key));
	path->pos_in_item = de->de_entry_num;
	if (retval != NAME_NOT_FOUND) {
		// ugly, but rename needs de_bh, de_deh, de_name, de_namelen, de_objectid set
		set_de_name_and_namelen(de);
		set_de_object_key(de);
	}
	return retval;
}
コード例 #6
0
ファイル: prints.c プロジェクト: fgeraci/cs518-sched
static int print_leaf (struct buffer_head * bh, int print_mode, int first, int last)
{
    struct block_head * blkh;
    struct item_head * ih;
    int i, nr;
    int from, to;

    if (!B_IS_ITEMS_LEVEL (bh))
	return 1;

    check_leaf (bh);

    blkh = B_BLK_HEAD (bh);
    ih = B_N_PITEM_HEAD (bh,0);
    nr = blkh_nr_item(blkh);

    printk ("\n===================================================================\n");
    reiserfs_warning ("LEAF NODE (%ld) contains %z\n", bh->b_blocknr, bh);

    if (!(print_mode & PRINT_LEAF_ITEMS)) {
	reiserfs_warning ("FIRST ITEM_KEY: %k, LAST ITEM KEY: %k\n",
			  &(ih->ih_key), &((ih + nr - 1)->ih_key));
	return 0;
    }

    if (first < 0 || first > nr - 1) 
	from = 0;
    else 
	from = first;

    if (last < 0 || last > nr )
	to = nr;
    else
	to = last;

    ih += from;
    printk ("-------------------------------------------------------------------------------\n");
    printk ("|##|   type    |           key           | ilen | free_space | version | loc  |\n");
    for (i = from; i < to; i++, ih ++) {
	printk ("-------------------------------------------------------------------------------\n");
	reiserfs_warning ("|%2d| %h |\n", i, ih);
	if (print_mode & PRINT_LEAF_ITEMS)
	    op_print_item (ih, B_I_PITEM (bh, ih));
    }

    printk ("===================================================================\n");

    return 0;
}
コード例 #7
0
ファイル: super.c プロジェクト: niubl/camera_project
// return pointer to appropriate function
static hashf_t hash_function (struct super_block * s)
{
    switch (what_hash (s)) {
    case TEA_HASH:
	reiserfs_warning ("Using tea hash to sort names\n");
	return keyed_hash;
    case YURA_HASH:
	reiserfs_warning ("Using rupasov hash to sort names\n");
	return yura_hash;
    case R5_HASH:
	reiserfs_warning ("Using r5 hash to sort names\n");
	return r5_hash;
    }
    return NULL;
}
コード例 #8
0
// if root directory is empty - we set default - Yura's - hash and
// warn about it
// FIXME: we look for only one name in a directory. If tea and yura
// bith have the same value - we ask user to send report to the
// mailing list
__u32 find_hash_out (struct super_block * s)
{
    int retval;
    struct inode * inode;
    struct cpu_key key;
    INITIALIZE_PATH (path);
    struct reiserfs_dir_entry de;
    __u32 hash = DEFAULT_HASH;

    inode = s->s_root->d_inode;

    while (1) {
	make_cpu_key (&key, inode, ~0, TYPE_DIRENTRY, 3);
	retval = search_by_entry_key (s, &key, &path, &de);
	if (retval == IO_ERROR) {
	    pathrelse (&path);
	    return UNSET_HASH ;
	}
	if (retval == NAME_NOT_FOUND)
	    de.de_entry_num --;
	set_de_name_and_namelen (&de);
	if (deh_offset( &(de.de_deh[de.de_entry_num]) ) == DOT_DOT_OFFSET) {
	    /* allow override in this case */
	    if (reiserfs_rupasov_hash(s)) {
		hash = YURA_HASH ;
	    }
	    reiserfs_warning("reiserfs: FS seems to be empty, autodetect "
	                     "is using the default hash\n");
	    break;
	}
	if (GET_HASH_VALUE(yura_hash (de.de_name, de.de_namelen)) == 
	    GET_HASH_VALUE(keyed_hash (de.de_name, de.de_namelen))) {
	    reiserfs_warning ("reiserfs: Could not detect hash function "
			      "please mount with -o hash={tea,rupasov,r5}\n") ;
	    hash = UNSET_HASH ;
	    break;
	}
	if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) ==
	    GET_HASH_VALUE (yura_hash (de.de_name, de.de_namelen)))
	    hash = YURA_HASH;
	else
	    hash = TEA_HASH;
	break;
    }

    pathrelse (&path);
    return hash;
}
コード例 #9
0
int reiserfs_proc_info_init(struct super_block *sb)
{
	char b[BDEVNAME_SIZE];
	char *s;

	/* Some block devices use /'s */
	strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE);
	s = strchr(b, '/');
	if (s)
		*s = '!';

	spin_lock_init(&__PINFO(sb).lock);
	REISERFS_SB(sb)->procdir = proc_mkdir_data(b, 0, proc_info_root, sb);
	if (REISERFS_SB(sb)->procdir) {
		add_file(sb, "version", show_version);
		add_file(sb, "super", show_super);
		add_file(sb, "per-level", show_per_level);
		add_file(sb, "bitmap", show_bitmap);
		add_file(sb, "on-disk-super", show_on_disk_super);
		add_file(sb, "oidmap", show_oidmap);
		add_file(sb, "journal", show_journal);
		return 0;
	}
	reiserfs_warning(sb, "cannot create /proc/%s/%s",
			 proc_info_root_name, b);
	return 1;
}
コード例 #10
0
ファイル: super.c プロジェクト: muromec/linux-ezxdev
static int read_bitmaps (struct super_block * s)
{
    int i, bmp;

    SB_AP_BITMAP (s) = vmalloc (sizeof (struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
    if (SB_AP_BITMAP (s) == 0)
      return 1;
    memset (SB_AP_BITMAP (s), 0, sizeof (struct reiserfs_bitmap_info) * SB_BMAP_NR(s));

    for (i = 0, bmp = REISERFS_DISK_OFFSET_IN_BYTES / s->s_blocksize + 1;
 	 i < SB_BMAP_NR(s); i++, bmp = s->s_blocksize * 8 * i) {
      SB_AP_BITMAP (s)[i].bh = sb_getblk (s, bmp);
      if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh))
	ll_rw_block(READ, 1, &SB_AP_BITMAP(s)[i].bh); 
    }
    for (i = 0; i < SB_BMAP_NR(s); i++) {
      wait_on_buffer(SB_AP_BITMAP (s)[i].bh);
      if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
	reiserfs_warning("sh-2029: reiserfs read_bitmaps: "
			 "bitmap block (#%lu) reading failed\n",
			 SB_AP_BITMAP(s)[i].bh->b_blocknr);
	for (i = 0; i < SB_BMAP_NR(s); i++)
	  brelse(SB_AP_BITMAP(s)[i].bh);
	vfree(SB_AP_BITMAP(s));
	SB_AP_BITMAP(s) = NULL;
	return 1;
      }
      load_bitmap_info_data (s, SB_AP_BITMAP (s) + i);
    }   
    return 0;
}
コード例 #11
0
ファイル: super.c プロジェクト: niubl/camera_project
static int read_bitmaps (struct super_block * s)
{
    int i, bmp;

    SB_AP_BITMAP (s) = reiserfs_kmalloc (sizeof (struct buffer_head *) * SB_BMAP_NR(s), GFP_NOFS, s);
    if (SB_AP_BITMAP (s) == 0)
      return 1;
    for (i = 0, bmp = REISERFS_DISK_OFFSET_IN_BYTES / s->s_blocksize + 1;
 	 i < SB_BMAP_NR(s); i++, bmp = s->s_blocksize * 8 * i) {
      SB_AP_BITMAP (s)[i] = getblk (s->s_dev, bmp, s->s_blocksize);
      if (!buffer_uptodate(SB_AP_BITMAP(s)[i]))
	ll_rw_block(READ, 1, SB_AP_BITMAP(s) + i); 
    }
    for (i = 0; i < SB_BMAP_NR(s); i++) {
      wait_on_buffer(SB_AP_BITMAP (s)[i]);
      if (!buffer_uptodate(SB_AP_BITMAP(s)[i])) {
	reiserfs_warning("sh-2029: reiserfs read_bitmaps: "
			 "bitmap block (#%lu) reading failed\n",
			 SB_AP_BITMAP(s)[i]->b_blocknr);
	for (i = 0; i < SB_BMAP_NR(s); i++)
	  brelse(SB_AP_BITMAP(s)[i]);
	reiserfs_kfree(SB_AP_BITMAP(s), sizeof(struct buffer_head *) * SB_BMAP_NR(s), s);
	SB_AP_BITMAP(s) = NULL;
	return 1;
      }
    }   
    return 0;
}
コード例 #12
0
ファイル: super.c プロジェクト: muromec/linux-ezxdev
static void reiserfs_put_super (struct super_block * s)
{
  int i;
  struct reiserfs_transaction_handle th ;
  
  /* change file system state to current state if it was mounted with read-write permissions */
  if (!(s->s_flags & MS_RDONLY)) {
    journal_begin(&th, s, 10) ;
    reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
    set_sb_state( SB_DISK_SUPER_BLOCK(s), s->u.reiserfs_sb.s_mount_state );
    journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
  }

  /* note, journal_release checks for readonly mount, and can decide not
  ** to do a journal_end
  */
  journal_release(&th, s) ;

  for (i = 0; i < SB_BMAP_NR (s); i ++)
    brelse (SB_AP_BITMAP (s)[i].bh);

  vfree (SB_AP_BITMAP (s));

  brelse (SB_BUFFER_WITH_SB (s));

  print_statistics (s);

  if (s->u.reiserfs_sb.s_kmallocs != 0) {
    reiserfs_warning ("vs-2004: reiserfs_put_super: allocated memory left %d\n",
		      s->u.reiserfs_sb.s_kmallocs);
  }

  if (s->u.reiserfs_sb.reserved_blocks != 0) {
    reiserfs_warning ("green-2005: reiserfs_put_super: reserved blocks left %d\n",
		      s->u.reiserfs_sb.reserved_blocks);
  }

  reiserfs_proc_unregister( s, "journal" );
  reiserfs_proc_unregister( s, "oidmap" );
  reiserfs_proc_unregister( s, "on-disk-super" );
  reiserfs_proc_unregister( s, "bitmap" );
  reiserfs_proc_unregister( s, "per-level" );
  reiserfs_proc_unregister( s, "super" );
  reiserfs_proc_unregister( s, "version" );
  reiserfs_proc_info_done( s );
  return;
}
コード例 #13
0
ファイル: xattr.c プロジェクト: mb3dot/community-b3-kernel
/*
 * Inode operation listxattr()
 *
 * We totally ignore the generic listxattr here because it would be stupid
 * not to. Since the xattrs are organized in a directory, we can just
 * readdir to find them.
 */
ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
{
	struct dentry *dir;
	int err = 0;
	loff_t pos = 0;
	struct listxattr_buf buf = {
		.dentry = dentry,
		.buf = buffer,
		.size = buffer ? size : 0,
	};

	if (!dentry->d_inode)
		return -EINVAL;

	if (!dentry->d_sb->s_xattr ||
	    get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
		return -EOPNOTSUPP;

	dir = open_xa_dir(dentry->d_inode, XATTR_REPLACE);
	if (IS_ERR(dir)) {
		err = PTR_ERR(dir);
		if (err == -ENODATA)
			err = 0;  /* Not an error if there aren't any xattrs */
		goto out;
	}

	mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR);
	err = reiserfs_readdir_dentry(dir, &buf, listxattr_filler, &pos);
	mutex_unlock(&dir->d_inode->i_mutex);

	if (!err)
		err = buf.pos;

	dput(dir);
out:
	return err;
}

static int create_privroot(struct dentry *dentry)
{
	int err;
	struct inode *inode = dentry->d_parent->d_inode;
	WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));

	err = xattr_mkdir(inode, dentry, 0700);
	if (err || !dentry->d_inode) {
		reiserfs_warning(dentry->d_sb, "jdm-20006",
				 "xattrs/ACLs enabled and couldn't "
				 "find/create .reiserfs_priv. "
				 "Failing mount.");
		return -EOPNOTSUPP;
	}

	dentry->d_inode->i_flags |= S_PRIVATE;
	reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr "
		      "storage.\n", PRIVROOT_NAME);

	return 0;
}
コード例 #14
0
ファイル: bitmap.c プロジェクト: Dronevery/JetsonTK1-kernel
int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value)
{
    int i, j;

    if (block == 0 || block >= SB_BLOCK_COUNT (s)) {
        reiserfs_warning (s, "vs-4010: is_reusable: block number is out of range %lu (%u)",
                          block, SB_BLOCK_COUNT (s));
        return 0;
    }

    /* it can't be one of the bitmap blocks */
    for (i = 0; i < SB_BMAP_NR (s); i ++)
        if (block == SB_AP_BITMAP (s)[i].bh->b_blocknr) {
            reiserfs_warning (s, "vs: 4020: is_reusable: "
                              "bitmap block %lu(%u) can't be freed or reused",
                              block, SB_BMAP_NR (s));
            return 0;
        }

    get_bit_address (s, block, &i, &j);

    if (i >= SB_BMAP_NR (s)) {
        reiserfs_warning (s, "vs-4030: is_reusable: there is no so many bitmap blocks: "
                          "block=%lu, bitmap_nr=%d", block, i);
        return 0;
    }

    if ((bit_value == 0 &&
            reiserfs_test_le_bit(j, SB_AP_BITMAP(s)[i].bh->b_data)) ||
            (bit_value == 1 &&
             reiserfs_test_le_bit(j, SB_AP_BITMAP (s)[i].bh->b_data) == 0)) {
        reiserfs_warning (s, "vs-4040: is_reusable: corresponding bit of block %lu does not "
                          "match required value (i==%d, j==%d) test_bit==%d",
                          block, i, j, reiserfs_test_le_bit (j, SB_AP_BITMAP (s)[i].bh->b_data));

        return 0;
    }

    if (bit_value == 0 && block == SB_ROOT_BLOCK (s)) {
        reiserfs_warning (s, "vs-4050: is_reusable: this is root block (%u), "
                          "it must be busy", SB_ROOT_BLOCK (s));
        return 0;
    }

    return 1;
}
コード例 #15
0
ファイル: xattr.c プロジェクト: ANFS/ANFS-kernel
/* inode->i_mutex: down */
int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
{
	int err = reiserfs_for_each_xattr(inode, chown_one_xattr, attrs);
	if (err)
		reiserfs_warning(inode->i_sb, "jdm-20007",
				 "Couldn't chown all xattrs (%d)\n", err);
	return err;
}
コード例 #16
0
ファイル: bitmap.c プロジェクト: Dronevery/JetsonTK1-kernel
static void _reiserfs_free_block (struct reiserfs_transaction_handle *th,
                                  struct inode *inode, b_blocknr_t block,
                                  int for_unformatted)
{
    struct super_block * s = th->t_super;
    struct reiserfs_super_block * rs;
    struct buffer_head * sbh;
    struct reiserfs_bitmap_info *apbi;
    int nr, offset;

    BUG_ON (!th->t_trans_id);

    PROC_INFO_INC( s, free_block );

    rs = SB_DISK_SUPER_BLOCK (s);
    sbh = SB_BUFFER_WITH_SB (s);
    apbi = SB_AP_BITMAP(s);

    get_bit_address (s, block, &nr, &offset);

    if (nr >= sb_bmap_nr (rs)) {
        reiserfs_warning (s, "vs-4075: reiserfs_free_block: "
                          "block %lu is out of range on %s",
                          block, reiserfs_bdevname (s));
        return;
    }

    reiserfs_prepare_for_journal(s, apbi[nr].bh, 1 ) ;

    /* clear bit for the given block in bit map */
    if (!reiserfs_test_and_clear_le_bit (offset, apbi[nr].bh->b_data)) {
        reiserfs_warning (s, "vs-4080: reiserfs_free_block: "
                          "free_block (%s:%lu)[dev:blocknr]: bit already cleared",
                          reiserfs_bdevname (s), block);
    }
    apbi[nr].free_count ++;
    journal_mark_dirty (th, s, apbi[nr].bh);

    reiserfs_prepare_for_journal(s, sbh, 1) ;
    /* update super block */
    set_sb_free_blocks( rs, sb_free_blocks(rs) + 1 );

    journal_mark_dirty (th, s, sbh);
    if (for_unformatted)
        DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
}
コード例 #17
0
ファイル: super.c プロジェクト: niubl/camera_project
static void handle_attrs( struct super_block *s )
{
	struct reiserfs_super_block * rs;

	if( reiserfs_attrs( s ) ) {
		rs = SB_DISK_SUPER_BLOCK (s);
		if( old_format_only(s) ) {
			reiserfs_warning( "reiserfs: cannot support attributes on 3.5.x disk format\n" );
			s -> u.reiserfs_sb.s_mount_opt &= ~ ( 1 << REISERFS_ATTRS );
			return;
		}
		if( !( le32_to_cpu( rs -> s_flags ) & reiserfs_attrs_cleared ) ) {
				reiserfs_warning( "reiserfs: cannot support attributes until flag is set in super-block\n" );
				s -> u.reiserfs_sb.s_mount_opt &= ~ ( 1 << REISERFS_ATTRS );
		}
	}
}
コード例 #18
0
ファイル: xattr.c プロジェクト: ANFS/ANFS-kernel
/* No i_mutex, but the inode is unconnected. */
int reiserfs_delete_xattrs(struct inode *inode)
{
	int err = reiserfs_for_each_xattr(inode, delete_one_xattr, NULL);
	if (err)
		reiserfs_warning(inode->i_sb, "jdm-20004",
				 "Couldn't delete all xattrs (%d)\n", err);
	return err;
}
コード例 #19
0
ファイル: buffer2.c プロジェクト: JBTech/ralink_rt5350
/* when we allocate a new block (get_new_buffer, get_empty_nodes) and
   get buffer for it, it is possible that it is held by someone else
   or even by this process. In this function we wait until all other
   holders release buffer. To make sure, that current process does not
   hold we did free all buffers in tree balance structure
   (get_empty_nodes and get_nodes_for_preserving) or in path structure
   only (get_new_buffer) just before calling this */
void wait_buffer_until_released (const struct buffer_head * bh)
{
  int repeat_counter = 0;

  while (atomic_read (&(bh->b_count)) > 1) {

    if ( !(++repeat_counter % 30000000) ) {
      reiserfs_warning (NULL, "vs-3050: wait_buffer_until_released: nobody releases buffer (%b). Still waiting (%d) %cJDIRTY %cJWAIT\n",
			bh, repeat_counter, buffer_journaled(bh) ? ' ' : '!',
			buffer_journal_dirty(bh) ? ' ' : '!');
    }
    run_task_queue(&tq_disk);
    yield();
  }
  if (repeat_counter > 30000000) {
    reiserfs_warning(NULL, "vs-3051: done waiting, ignore vs-3050 messages for (%b)\n", bh) ;
  }
}
コード例 #20
0
static void _reiserfs_free_block (struct reiserfs_transaction_handle *th,
                                  b_blocknr_t block)
{
    struct super_block * s = th->t_super;
    struct reiserfs_super_block * rs;
    struct buffer_head * sbh;
    struct reiserfs_bitmap_info *apbi;
    int nr, offset;

    PROC_INFO_INC( s, free_block );

    rs = SB_DISK_SUPER_BLOCK (s);
    sbh = SB_BUFFER_WITH_SB (s);
    apbi = SB_AP_BITMAP(s);

    get_bit_address (s, block, &nr, &offset);

    if (nr >= sb_bmap_nr (rs)) {
        reiserfs_warning ("vs-4075: reiserfs_free_block: "
                          "block %lu is out of range on %s\n",
                          block, bdevname(s->s_dev));
        return;
    }

    reiserfs_prepare_for_journal(s, apbi[nr].bh, 1 ) ;

    /* clear bit for the given block in bit map */
    if (!reiserfs_test_and_clear_le_bit (offset, apbi[nr].bh->b_data)) {
        reiserfs_warning ("vs-4080: reiserfs_free_block: "
                          "free_block (%04x:%lu)[dev:blocknr]: bit already cleared\n",
                          s->s_dev, block);
    }
    if (offset < apbi[nr].first_zero_hint) {
        apbi[nr].first_zero_hint = offset;
    }
    apbi[nr].free_count ++;
    journal_mark_dirty (th, s, apbi[nr].bh);

    reiserfs_prepare_for_journal(s, sbh, 1) ;
    /* update super block */
    set_sb_free_blocks( rs, sb_free_blocks(rs) + 1 );

    journal_mark_dirty (th, s, sbh);
}
コード例 #21
0
/* read bitmap blocks */
void reiserfs_read_bitmap_blocks (reiserfs_filsys_t fs)
{
	struct reiserfs_super_block * rs = fs->s_rs;
	struct buffer_head * bh = SB_BUFFER_WITH_SB(fs);
	int fd = fs->s_dev;
	unsigned long block;
	int i;
	
	/* read bitmaps, and correct a bit if necessary */
	SB_AP_BITMAP (fs) = getmem (sizeof (void *) * rs_bmap_nr (rs));
	for (i = 0, block = bh->b_blocknr + 1;
	     i < rs_bmap_nr (rs); i ++) {
		SB_AP_BITMAP (fs)[i] = bread (fd, block, fs->s_blocksize);
		if (!SB_AP_BITMAP (fs)[i]) {
		    	reiserfs_warning (stderr, "reiserfs_open: bread failed reading bitmap #%d (%lu)\n", i, block);
			SB_AP_BITMAP (fs)[i] = getblk (fd, block, fs->s_blocksize);
			memset (SB_AP_BITMAP (fs)[i]->b_data, 0xff, fs->s_blocksize);
			set_bit (BH_Uptodate, &SB_AP_BITMAP (fs)[i]->b_state);
		}
		
		/* all bitmaps have to have itself marked used on it */
		if (bh->b_blocknr == 16) {
			if (!test_bit (block % (fs->s_blocksize * 8), SB_AP_BITMAP (fs)[i]->b_data)) {
				reiserfs_warning (stderr, "reiserfs_open: bitmap %d was marked free\n", i);
				/*set_bit (block % (fs->s_blocksize * 8), SB_AP_BITMAP (fs)[i]->b_data);*/
			}
		} else {
			/* bitmap not spread over partition: fixme: does not
			   work when number of bitmaps => 32768 */
			if (!test_bit (block, SB_AP_BITMAP (fs)[0]->b_data)) {
			    	reiserfs_warning (stderr, "reiserfs_open: bitmap %d was marked free\n", i);
				/*set_bit (block, SB_AP_BITMAP (fs)[0]->b_data);*/
			}
		}

		if (i == 0) {
			/* first bitmap has to have marked used super block
			   and journal areas */
			check_first_bitmap (fs, SB_AP_BITMAP (fs)[i]->b_data);
		}

		block = (bh->b_blocknr == 16 ? ((i + 1) * fs->s_blocksize * 8) : (block + 1));
    }
}
コード例 #22
0
ファイル: bitmap.c プロジェクト: liexusong/Linux-2.4.16
void reiserfs_discard_prealloc (struct reiserfs_transaction_handle *th, 
				struct inode * inode)
{
#ifdef CONFIG_REISERFS_CHECK
  if (inode->u.reiserfs_i.i_prealloc_count < 0)
     reiserfs_warning("zam-4001:" __FUNCTION__ ": inode has negative prealloc blocks count.\n");
#endif  
    if (inode->u.reiserfs_i.i_prealloc_count > 0) {
    __discard_prealloc(th, inode);
  }
      }
コード例 #23
0
ファイル: procfs.c プロジェクト: fgeraci/cs518-sched
int reiserfs_proc_info_init( struct super_block *sb )
{
	spin_lock_init( & __PINFO( sb ).lock );
	sb->u.reiserfs_sb.procdir = proc_mkdir(sb->s_id, proc_info_root);
	if( sb->u.reiserfs_sb.procdir ) {
		sb->u.reiserfs_sb.procdir -> owner = THIS_MODULE;
		return 0;
	}
	reiserfs_warning( "reiserfs: cannot create /proc/%s/%s\n",
			  proc_info_root_name, sb->s_id );
	return 1;
}
コード例 #24
0
int reiserfs_proc_info_global_init(void)
{
	if (proc_info_root == NULL) {
		proc_info_root = proc_mkdir(proc_info_root_name, NULL);
		if (!proc_info_root) {
			reiserfs_warning(NULL, "cannot create /proc/%s",
					 proc_info_root_name);
			return 1;
		}
	}
	return 0;
}
コード例 #25
0
ファイル: stree.c プロジェクト: pemargo/asuswrt-merlin
// make sure that bh contains formatted node of reiserfs tree of
// 'level'-th level
static int is_tree_node(struct buffer_head *bh, int level)
{
	if (B_LEVEL(bh) != level) {
		reiserfs_warning(NULL, "reiserfs-5090", "node level %d does "
				 "not match to the expected one %d",
				 B_LEVEL(bh), level);
		return 0;
	}
	if (level == DISK_LEAF_NODE_LEVEL)
		return is_leaf(bh->b_data, bh->b_size, bh);

	return is_internal(bh->b_data, bh->b_size, bh);
}
コード例 #26
0
ファイル: prints.c プロジェクト: BackupTheBerlios/wl530g-svn
void print_directory_item (FILE * fp, reiserfs_filsys_t fs,
			   struct buffer_head * bh, struct item_head * ih)
{
    int i;
    int namelen;
    struct reiserfs_de_head * deh;
    char * name;
/*    static char namebuf [80];*/

    if (!I_IS_DIRECTORY_ITEM (ih))
	return;

    //printk ("\n%2%-25s%-30s%-15s%-15s%-15s\n", "    Name", "length", "Object key", "Hash", "Gen number", "Status");
    reiserfs_warning (fp, "%3s: %-25s%s%-22s%-12s%s\n", "###", "Name", "length", "    Object key", "   Hash", "Gen number");
    deh = B_I_DEH (bh, ih);
    for (i = 0; i < ih_entry_count (ih); i ++, deh ++) {
	if (dir_entry_bad_location (deh, ih, i == 0 ? 1 : 0)) {
	    reiserfs_warning (fp, "%3d: wrong entry location %u, deh_offset %u\n",
			      i, deh_location (deh), deh_offset (deh));
	    continue;
	}
	if (i && dir_entry_bad_location (deh - 1, ih, ((i - 1) == 0) ? 1 : 0))
	    /* previous entry has bad location so we can not calculate entry
               length */
	    namelen = 25;
	else
	    namelen = name_length (ih, deh, i);

	name = name_in_entry (deh, i);
	reiserfs_warning (fp, "%3d: \"%-25.*s\"(%3d)%20K%12d%5d, loc %u, state %x %s\n", 
			  i, namelen, name, namelen,
                          /* this gets converted in print_short_key() */
			  (struct key *)&(deh->deh_dir_id),
			  GET_HASH_VALUE (deh_offset(deh)),
                          GET_GENERATION_NUMBER (deh_offset(deh)),
			  deh_location (deh), deh_state(deh),
			  fs ? (is_properly_hashed (fs, name, namelen, deh_offset (deh)) ? "" : "(BROKEN)") : "??");
    }
}
コード例 #27
0
int reiserfs_proc_info_global_init( void )
{
	if( proc_info_root == NULL ) {
		proc_info_root = proc_mkdir( proc_info_root_name, 0 );
		if( proc_info_root ) {
			proc_info_root -> owner = THIS_MODULE;
		} else {
			reiserfs_warning( "reiserfs: cannot create /proc/%s\n",
					  proc_info_root_name );
			return 1;
		}
	}
	return 0;
}
コード例 #28
0
void reiserfs_discard_all_prealloc (struct reiserfs_transaction_handle *th)
{
    struct list_head * plist = &SB_JOURNAL(th->t_super)->j_prealloc_list;
    struct inode * inode;

    while (!list_empty(plist)) {
        inode = list_entry(plist->next, struct inode, u.reiserfs_i.i_prealloc_list);
#ifdef CONFIG_REISERFS_CHECK
        if (!inode->u.reiserfs_i.i_prealloc_count) {
            reiserfs_warning("zam-4001:%s: inode is in prealloc list but has no preallocated blocks.\n", __FUNCTION__ );
        }
#endif
        __discard_prealloc(th, inode);
    }
}
コード例 #29
0
ファイル: bitmap.c プロジェクト: xricson/knoppix
static void __discard_prealloc (struct reiserfs_transaction_handle * th,
				struct reiserfs_inode_info *ei)
{
    unsigned long save = ei->i_prealloc_block ;
#ifdef CONFIG_REISERFS_CHECK
    if (ei->i_prealloc_count < 0)
	reiserfs_warning("zam-4001:%s: inode has negative prealloc blocks count.\n", __FUNCTION__ );
#endif
    while (ei->i_prealloc_count > 0) {
	reiserfs_free_prealloc_block(th,ei->i_prealloc_block);
	ei->i_prealloc_block++;
	ei->i_prealloc_count --;
    }
    ei->i_prealloc_block = save;
    list_del_init(&(ei->i_prealloc_list));
}
コード例 #30
0
static void __discard_prealloc (struct reiserfs_transaction_handle * th,
                                struct inode * inode)
{
    unsigned long save = inode->u.reiserfs_i.i_prealloc_block ;
#ifdef CONFIG_REISERFS_CHECK
    if (inode->u.reiserfs_i.i_prealloc_count < 0)
        reiserfs_warning("zam-4001:%s: inode has negative prealloc blocks count.\n", __FUNCTION__ );
#endif
    while (inode->u.reiserfs_i.i_prealloc_count > 0) {
        reiserfs_free_prealloc_block(th,inode->u.reiserfs_i.i_prealloc_block);
        inode->u.reiserfs_i.i_prealloc_block++;
        inode->u.reiserfs_i.i_prealloc_count --;
    }
    inode->u.reiserfs_i.i_prealloc_block = save ;
    list_del (&(inode->u.reiserfs_i.i_prealloc_list));
}