您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ubh_get_ucg函数代码示例

51自学网 2021-06-03 09:04:38
  C++
这篇教程C++ ubh_get_ucg函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中ubh_get_ucg函数的典型用法代码示例。如果您正苦于以下问题:C++ ubh_get_ucg函数的具体用法?C++ ubh_get_ucg怎么用?C++ ubh_get_ucg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了ubh_get_ucg函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ufs_alloccg_block

static u64 ufs_alloccg_block(struct inode *inode,			     struct ufs_cg_private_info *ucpi,			     u64 goal, int *err){	struct super_block * sb;	struct ufs_sb_private_info * uspi;	struct ufs_super_block_first * usb1;	struct ufs_cylinder_group * ucg;	u64 result, blkno;	UFSD("ENTER, goal %llu/n", (unsigned long long)goal);	sb = inode->i_sb;	uspi = UFS_SB(sb)->s_uspi;	usb1 = ubh_get_usb_first(uspi);	ucg = ubh_get_ucg(UCPI_UBH(ucpi));	if (goal == 0) {		goal = ucpi->c_rotor;		goto norot;	}	goal = ufs_blknum (goal);	goal = ufs_dtogd(uspi, goal);		/*	 * If the requested block is available, use it.	 */	if (ubh_isblockset(UCPI_UBH(ucpi), ucpi->c_freeoff, ufs_fragstoblks(goal))) {		result = goal;		goto gotit;	}	norot:		result = ufs_bitmap_search (sb, ucpi, goal, uspi->s_fpb);	if (result == INVBLOCK)		return INVBLOCK;	ucpi->c_rotor = result;gotit:	blkno = ufs_fragstoblks(result);	ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno);	if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)		ufs_clusteracct (sb, ucpi, blkno, -1);	fs32_sub(sb, &ucg->cg_cs.cs_nbfree, 1);	uspi->cs_total.cs_nbfree--;	fs32_sub(sb, &UFS_SB(sb)->fs_cs(ucpi->c_cgx).cs_nbfree, 1);	if (uspi->fs_magic != UFS2_MAGIC) {		unsigned cylno = ufs_cbtocylno((unsigned)result);		fs16_sub(sb, &ubh_cg_blks(ucpi, cylno,					  ufs_cbtorpos((unsigned)result)), 1);		fs32_sub(sb, &ubh_cg_blktot(ucpi, cylno), 1);	}		UFSD("EXIT, result %llu/n", (unsigned long long)result);	return result;}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:59,


示例2: ufs_put_cylinder

/* * Remove cylinder group from cache, doesn't release memory * allocated for cylinder group (this is done at ufs_put_super only). */void ufs_put_cylinder (struct super_block * sb, unsigned bitmap_nr){	struct ufs_sb_info * sbi = UFS_SB(sb);	struct ufs_sb_private_info * uspi; 	struct ufs_cg_private_info * ucpi;	struct ufs_cylinder_group * ucg;	unsigned i;	UFSD("ENTER, bitmap_nr %u/n", bitmap_nr);	uspi = sbi->s_uspi;	if (sbi->s_cgno[bitmap_nr] == UFS_CGNO_EMPTY) {		UFSD("EXIT/n");		return;	}	ucpi = sbi->s_ucpi[bitmap_nr];	ucg = ubh_get_ucg(UCPI_UBH(ucpi));	if (uspi->s_ncg > UFS_MAX_GROUP_LOADED && bitmap_nr >= sbi->s_cg_loaded) {		ufs_panic (sb, "ufs_put_cylinder", "internal error");		return;	}	/*	 * rotor is not so important data, so we put it to disk 	 * at the end of working with cylinder	 */	ucg->cg_rotor = cpu_to_fs32(sb, ucpi->c_rotor);	ucg->cg_frotor = cpu_to_fs32(sb, ucpi->c_frotor);	ucg->cg_irotor = cpu_to_fs32(sb, ucpi->c_irotor);	ubh_mark_buffer_dirty (UCPI_UBH(ucpi));	for (i = 1; i < UCPI_UBH(ucpi)->count; i++) {		brelse (UCPI_UBH(ucpi)->bh[i]);	}	sbi->s_cgno[bitmap_nr] = UFS_CGNO_EMPTY;	UFSD("EXIT/n");}
开发者ID:020gzh,项目名称:linux,代码行数:41,


示例3: ufs_free_inode

/* * NOTE! When we get the inode, we're the only people * that have access to it, and as such there are no * race conditions we have to worry about. The inode * is not on the hash-lists, and it cannot be reached * through the filesystem because the directory entry * has been deleted earlier. * * HOWEVER: we must make sure that we get no aliases, * which means that we have to call "clear_inode()" * _before_ we mark the inode not in use in the inode * bitmaps. Otherwise a newly created file might use * the same inode number (not actually the same pointer * though), and then we'd have two inodes sharing the * same inode number and space on the harddisk. */void ufs_free_inode (struct inode * inode){    struct super_block * sb;    struct ufs_sb_private_info * uspi;    struct ufs_super_block_first * usb1;    struct ufs_cg_private_info * ucpi;    struct ufs_cylinder_group * ucg;    int is_directory;    unsigned ino, cg, bit;        UFSD("ENTER, ino %lu/n", inode->i_ino);    sb = inode->i_sb;    uspi = UFS_SB(sb)->s_uspi;    usb1 = ubh_get_usb_first(uspi);        ino = inode->i_ino;    lock_super (sb);    if (!((ino > 1) && (ino < (uspi->s_ncg * uspi->s_ipg )))) {        ufs_warning(sb, "ufs_free_inode", "reserved inode or nonexistent inode %u/n", ino);        unlock_super (sb);        return;    }        cg = ufs_inotocg (ino);    bit = ufs_inotocgoff (ino);    ucpi = ufs_load_cylinder (sb, cg);    if (!ucpi) {        unlock_super (sb);        return;    }    ucg = ubh_get_ucg(UCPI_UBH(ucpi));    if (!ufs_cg_chkmagic(sb, ucg))        ufs_panic (sb, "ufs_free_fragments", "internal error, bad cg magic number");    ucg->cg_time = cpu_to_fs32(sb, get_seconds());    is_directory = S_ISDIR(inode->i_mode);    DQUOT_FREE_INODE(inode);    DQUOT_DROP(inode);    clear_inode (inode);    if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit))        ufs_error(sb, "ufs_free_inode", "bit already cleared for inode %u", ino);    else {        ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit);        if (ino < ucpi->c_irotor)            ucpi->c_irotor = ino;        fs32_add(sb, &ucg->cg_cs.cs_nifree, 1);        uspi->cs_total.cs_nifree++;        fs32_add(sb, &UFS_SB(sb)->fs_cs(cg).cs_nifree, 1);        if (is_directory) {            fs32_sub(sb, &ucg->cg_cs.cs_ndir, 1);            uspi->cs_total.cs_ndir--;            fs32_sub(sb, &UFS_SB(sb)->fs_cs(cg).cs_ndir, 1);        }    }    ubh_mark_buffer_dirty (USPI_UBH(uspi));    ubh_mark_buffer_dirty (UCPI_UBH(ucpi));    if (sb->s_flags & MS_SYNCHRONOUS) {        ubh_ll_rw_block(SWRITE, UCPI_UBH(ucpi));        ubh_wait_on_buffer (UCPI_UBH(ucpi));    }        sb->s_dirt = 1;    unlock_super (sb);    UFSD("EXIT/n");}
开发者ID:274914765,项目名称:C,代码行数:90,


示例4: ufs_new_inode

/* * There are two policies for allocating an inode.  If the new inode is * a directory, then a forward search is made for a block group with both * free space and a low directory-to-inode ratio; if that fails, then of * the groups with above-average free space, that group with the fewest * directories already is chosen. * * For other inodes, search forward from the parent directory's block * group to find a free inode. */struct inode * ufs_new_inode(struct inode * dir, int mode){    struct super_block * sb;    struct ufs_sb_info * sbi;    struct ufs_sb_private_info * uspi;    struct ufs_super_block_first * usb1;    struct ufs_cg_private_info * ucpi;    struct ufs_cylinder_group * ucg;    struct inode * inode;    unsigned cg, bit, i, j, start;    struct ufs_inode_info *ufsi;    int err = -ENOSPC;    UFSD("ENTER/n");        /* Cannot create files in a deleted directory */    if (!dir || !dir->i_nlink)        return ERR_PTR(-EPERM);    sb = dir->i_sb;    inode = new_inode(sb);    if (!inode)        return ERR_PTR(-ENOMEM);    ufsi = UFS_I(inode);    sbi = UFS_SB(sb);    uspi = sbi->s_uspi;    usb1 = ubh_get_usb_first(uspi);    lock_super (sb);    /*     * Try to place the inode in its parent directory     */    i = ufs_inotocg(dir->i_ino);    if (sbi->fs_cs(i).cs_nifree) {        cg = i;        goto cg_found;    }    /*     * Use a quadratic hash to find a group with a free inode     */    for ( j = 1; j < uspi->s_ncg; j <<= 1 ) {        i += j;        if (i >= uspi->s_ncg)            i -= uspi->s_ncg;        if (sbi->fs_cs(i).cs_nifree) {            cg = i;            goto cg_found;        }    }    /*     * That failed: try linear search for a free inode     */    i = ufs_inotocg(dir->i_ino) + 1;    for (j = 2; j < uspi->s_ncg; j++) {        i++;        if (i >= uspi->s_ncg)            i = 0;        if (sbi->fs_cs(i).cs_nifree) {            cg = i;            goto cg_found;        }    }    goto failed;cg_found:    ucpi = ufs_load_cylinder (sb, cg);    if (!ucpi) {        err = -EIO;        goto failed;    }    ucg = ubh_get_ucg(UCPI_UBH(ucpi));    if (!ufs_cg_chkmagic(sb, ucg))         ufs_panic (sb, "ufs_new_inode", "internal error, bad cg magic number");    start = ucpi->c_irotor;    bit = ubh_find_next_zero_bit (UCPI_UBH(ucpi), ucpi->c_iusedoff, uspi->s_ipg, start);    if (!(bit < uspi->s_ipg)) {        bit = ubh_find_first_zero_bit (UCPI_UBH(ucpi), ucpi->c_iusedoff, start);        if (!(bit < start)) {            ufs_error (sb, "ufs_new_inode",                "cylinder group %u corrupted - error in inode bitmap/n", cg);            err = -EIO;            goto failed;        }    }    UFSD("start = %u, bit = %u, ipg = %u/n", start, bit, uspi->s_ipg);    if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit))//.........这里部分代码省略.........
开发者ID:274914765,项目名称:C,代码行数:101,


示例5: ufs_new_inode

/* * There are two policies for allocating an inode.  If the new inode is * a directory, then a forward search is made for a block group with both * free space and a low directory-to-inode ratio; if that fails, then of * the groups with above-average free space, that group with the fewest * directories already is chosen. * * For other inodes, search forward from the parent directory's block * group to find a free inode. */struct inode * ufs_new_inode(struct inode * dir, int mode){	struct super_block * sb;	struct ufs_sb_info * sbi;	struct ufs_sb_private_info * uspi;	struct ufs_super_block_first * usb1;	struct ufs_cg_private_info * ucpi;	struct ufs_cylinder_group * ucg;	struct inode * inode;	unsigned cg, bit, i, j, start;	struct ufs_inode_info *ufsi;	UFSD(("ENTER/n"))		/* Cannot create files in a deleted directory */	if (!dir || !dir->i_nlink)		return ERR_PTR(-EPERM);	sb = dir->i_sb;	inode = new_inode(sb);	if (!inode)		return ERR_PTR(-ENOMEM);	ufsi = UFS_I(inode);	sbi = UFS_SB(sb);	uspi = sbi->s_uspi;	usb1 = ubh_get_usb_first(USPI_UBH);	lock_super (sb);	/*	 * Try to place the inode in its parent directory	 */	i = ufs_inotocg(dir->i_ino);	if (sbi->fs_cs(i).cs_nifree) {		cg = i;		goto cg_found;	}	/*	 * Use a quadratic hash to find a group with a free inode	 */	for ( j = 1; j < uspi->s_ncg; j <<= 1 ) {		i += j;		if (i >= uspi->s_ncg)			i -= uspi->s_ncg;		if (sbi->fs_cs(i).cs_nifree) {			cg = i;			goto cg_found;		}	}	/*	 * That failed: try linear search for a free inode	 */	i = ufs_inotocg(dir->i_ino) + 1;	for (j = 2; j < uspi->s_ncg; j++) {		i++;		if (i >= uspi->s_ncg)			i = 0;		if (sbi->fs_cs(i).cs_nifree) {			cg = i;			goto cg_found;		}	}		goto failed;cg_found:	ucpi = ufs_load_cylinder (sb, cg);	if (!ucpi)		goto failed;	ucg = ubh_get_ucg(UCPI_UBH);	if (!ufs_cg_chkmagic(sb, ucg)) 		ufs_panic (sb, "ufs_new_inode", "internal error, bad cg magic number");	start = ucpi->c_irotor;	bit = ubh_find_next_zero_bit (UCPI_UBH, ucpi->c_iusedoff, uspi->s_ipg, start);	if (!(bit < uspi->s_ipg)) {		bit = ubh_find_first_zero_bit (UCPI_UBH, ucpi->c_iusedoff, start);		if (!(bit < start)) {			ufs_error (sb, "ufs_new_inode",			    "cylinder group %u corrupted - error in inode bitmap/n", cg);			goto failed;		}	}	UFSD(("start = %u, bit = %u, ipg = %u/n", start, bit, uspi->s_ipg))	if (ubh_isclr (UCPI_UBH, ucpi->c_iusedoff, bit))		ubh_setbit (UCPI_UBH, ucpi->c_iusedoff, bit);	else {		ufs_panic (sb, "ufs_new_inode", "internal error");		goto failed;//.........这里部分代码省略.........
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:101,


示例6: ufs_free_fragments

/* * Free 'count' fragments from fragment number 'fragment' */void ufs_free_fragments (struct inode * inode, unsigned fragment, unsigned count) {	struct super_block * sb;	struct ufs_sb_private_info * uspi;	struct ufs_super_block_first * usb1;	struct ufs_cg_private_info * ucpi;	struct ufs_cylinder_group * ucg;	unsigned cgno, bit, end_bit, bbase, blkmap, i, blkno, cylno;	unsigned swab;		sb = inode->i_sb;	uspi = sb->u.ufs_sb.s_uspi;	swab = sb->u.ufs_sb.s_swab;	usb1 = ubh_get_usb_first(USPI_UBH);		UFSD(("ENTER, fragment %u, count %u/n", fragment, count))		if (ufs_fragnum(fragment) + count > uspi->s_fpg)		ufs_error (sb, "ufs_free_fragments", "internal error");		lock_super(sb);		cgno = ufs_dtog(fragment);	bit = ufs_dtogd(fragment);	if (cgno >= uspi->s_ncg) {		ufs_panic (sb, "ufs_free_fragments", "freeing blocks are outside device");		goto failed;	}			ucpi = ufs_load_cylinder (sb, cgno);	if (!ucpi) 		goto failed;	ucg = ubh_get_ucg (UCPI_UBH);	if (!ufs_cg_chkmagic (ucg)) {		ufs_panic (sb, "ufs_free_fragments", "internal error, bad magic number on cg %u", cgno);		goto failed;	}	end_bit = bit + count;	bbase = ufs_blknum (bit);	blkmap = ubh_blkmap (UCPI_UBH, ucpi->c_freeoff, bbase);	ufs_fragacct (sb, blkmap, ucg->cg_frsum, -1);	for (i = bit; i < end_bit; i++) {		if (ubh_isclr (UCPI_UBH, ucpi->c_freeoff, i))			ubh_setbit (UCPI_UBH, ucpi->c_freeoff, i);		else ufs_error (sb, "ufs_free_fragments",			"bit already cleared for fragment %u", i);	}		DQUOT_FREE_BLOCK (sb, inode, count);	ADD_SWAB32(ucg->cg_cs.cs_nffree, count);	ADD_SWAB32(usb1->fs_cstotal.cs_nffree, count);	ADD_SWAB32(sb->fs_cs(cgno).cs_nffree, count);	blkmap = ubh_blkmap (UCPI_UBH, ucpi->c_freeoff, bbase);	ufs_fragacct(sb, blkmap, ucg->cg_frsum, 1);	/*	 * Trying to reassemble free fragments into block	 */	blkno = ufs_fragstoblks (bbase);	if (ubh_isblockset(UCPI_UBH, ucpi->c_freeoff, blkno)) {		SUB_SWAB32(ucg->cg_cs.cs_nffree, uspi->s_fpb);		SUB_SWAB32(usb1->fs_cstotal.cs_nffree, uspi->s_fpb);		SUB_SWAB32(sb->fs_cs(cgno).cs_nffree, uspi->s_fpb);		if ((sb->u.ufs_sb.s_flags & UFS_CG_MASK) == UFS_CG_44BSD)			ufs_clusteracct (sb, ucpi, blkno, 1);		INC_SWAB32(ucg->cg_cs.cs_nbfree);		INC_SWAB32(usb1->fs_cstotal.cs_nbfree);		INC_SWAB32(sb->fs_cs(cgno).cs_nbfree);		cylno = ufs_cbtocylno (bbase);		INC_SWAB16(ubh_cg_blks (ucpi, cylno, ufs_cbtorpos(bbase)));		INC_SWAB32(ubh_cg_blktot (ucpi, cylno));	}		ubh_mark_buffer_dirty (USPI_UBH);	ubh_mark_buffer_dirty (UCPI_UBH);	if (sb->s_flags & MS_SYNCHRONOUS) {		ubh_ll_rw_block (WRITE, 1, (struct ufs_buffer_head **)&ucpi);		ubh_wait_on_buffer (UCPI_UBH);	}	sb->s_dirt = 1;		unlock_super (sb);	UFSD(("EXIT/n"))	return;failed:	unlock_super (sb);	UFSD(("EXIT (FAILED)/n"))	return;}
开发者ID:dmgerman,项目名称:original,代码行数:93,


示例7: ufs_free_blocks

/* * Free 'count' fragments from fragment number 'fragment' (free whole blocks) */void ufs_free_blocks (struct inode * inode, unsigned fragment, unsigned count) {	struct super_block * sb;	struct ufs_sb_private_info * uspi;	struct ufs_super_block_first * usb1;	struct ufs_cg_private_info * ucpi;	struct ufs_cylinder_group * ucg;	unsigned overflow, cgno, bit, end_bit, blkno, i, cylno;	unsigned swab;		sb = inode->i_sb;	uspi = sb->u.ufs_sb.s_uspi;	swab = sb->u.ufs_sb.s_swab;	usb1 = ubh_get_usb_first(USPI_UBH);	UFSD(("ENTER, fragment %u, count %u/n", fragment, count))		if ((fragment & uspi->s_fpbmask) || (count & uspi->s_fpbmask)) {		ufs_error (sb, "ufs_free_blocks", "internal error, "			"fragment %u, count %u/n", fragment, count);		goto failed;	}	lock_super(sb);	do_more:	overflow = 0;	cgno = ufs_dtog (fragment);	bit = ufs_dtogd (fragment);	if (cgno >= uspi->s_ncg) {		ufs_panic (sb, "ufs_free_blocks", "freeing blocks are outside device");		goto failed;	}	end_bit = bit + count;	if (end_bit > uspi->s_fpg) {		overflow = bit + count - uspi->s_fpg;		count -= overflow;		end_bit -= overflow;	}	ucpi = ufs_load_cylinder (sb, cgno);	if (!ucpi) 		goto failed;	ucg = ubh_get_ucg (UCPI_UBH);	if (!ufs_cg_chkmagic (ucg)) {		ufs_panic (sb, "ufs_free_blocks", "internal error, bad magic number on cg %u", cgno);		goto failed;	}	for (i = bit; i < end_bit; i += uspi->s_fpb) {		blkno = ufs_fragstoblks(i);		if (ubh_isblockset(UCPI_UBH, ucpi->c_freeoff, blkno)) {			ufs_error(sb, "ufs_free_blocks", "freeing free fragment");		}		ubh_setblock(UCPI_UBH, ucpi->c_freeoff, blkno);		if ((sb->u.ufs_sb.s_flags & UFS_CG_MASK) == UFS_CG_44BSD)			ufs_clusteracct (sb, ucpi, blkno, 1);		DQUOT_FREE_BLOCK(sb, inode, uspi->s_fpb);		INC_SWAB32(ucg->cg_cs.cs_nbfree);		INC_SWAB32(usb1->fs_cstotal.cs_nbfree);		INC_SWAB32(sb->fs_cs(cgno).cs_nbfree);		cylno = ufs_cbtocylno(i);		INC_SWAB16(ubh_cg_blks(ucpi, cylno, ufs_cbtorpos(i)));		INC_SWAB32(ubh_cg_blktot(ucpi, cylno));	}	ubh_mark_buffer_dirty (USPI_UBH);	ubh_mark_buffer_dirty (UCPI_UBH);	if (sb->s_flags & MS_SYNCHRONOUS) {		ubh_ll_rw_block (WRITE, 1, (struct ufs_buffer_head **)&ucpi);		ubh_wait_on_buffer (UCPI_UBH);	}	if (overflow) {		fragment += count;		count = overflow;		goto do_more;	}	sb->s_dirt = 1;	unlock_super (sb);	UFSD(("EXIT/n"))	return;failed:	unlock_super (sb);	UFSD(("EXIT (FAILED)/n"))	return;}
开发者ID:dmgerman,项目名称:original,代码行数:91,



注:本文中的ubh_get_ucg函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ ubh_get_usb_first函数代码示例
C++ ubase_check函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。