Linux里面block代表啥意思?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux里面block代表啥意思?相关的知识,希望对你有一定的参考价值。
参考技术A 在2.4 的 fs/buffers.c 的函数static int __block_prepare_write(struct inode *inode, struct page *page,
unsigned from, unsigned to, get_block_t *get_block)
中有如下代码:
if (!page->buffers)
create_empty_buffers(page, inode->i_dev, blocksize);
head = page->buffers;
bbits = inode->i_sb->s_blocksize_bits;
block = page->index << (PAGE_CACHE_SHIFT - bbits);
for(bh = head, block_start = 0; bh != head || !block_start;
block++, block_start=block_end, bh = bh->b_this_page)
if (!bh)
BUG();
block_end = block_start+blocksize;
if (block_end <= from)
continue;
if (block_start >= to)
break;
if (!buffer_mapped(bh))
err = get_block(inode, block, bh, 1);
if (err)
goto out;
if (buffer_new(bh))
unmap_underlying_metadata(bh);
if (Page_Uptodate(page))
set_bit(BH_Uptodate, &bh->b_state);
continue;
if (block_end > to)
memset(kaddr+to, 0, block_end-to);
if (block_start < from)
memset(kaddr+block_start, 0, from-block_start);
if (block_end > to || block_start < from)
flush_dcache_page(page);
continue;
对unmap_underlying_metadata 的意义不是特别明确, 注释说是释放潜在的bh. 实现是从hash中找到bh代表的设备上, bh-->blocknr 那个块的oldbh, 如果有的话把它释放.
奇怪的是,既然是新分配的,为什么在hash中能找到? 如果hash中本来就有, 需要新分配吗?
/*
* We are taking a block for data and we don't want any output from any
* buffer-cache aliases starting from return from that function and
* until the moment when something will explicitly mark the buffer
* dirty (hopefully that will not happen until we will free that block ;-)
* We don't even need to mark it not-uptodate - nobody can expect
* anything from a newly allocated buffer anyway. We used to used
* unmap_buffer() for such invalidation, but that was wrong. We definitely
* don't want to mark the alias unmapped, for example - it would confuse
* anyone who might pick it with bread() afterwards...
*/
static void unmap_underlying_metadata(struct buffer_head * bh)
struct buffer_head *old_bh;
old_bh = get_hash_table(bh->b_dev, bh->b_blocknr, bh->b_size);
if (old_bh)
mark_buffer_clean(old_bh);
wait_on_buffer(old_bh);
clear_bit(BH_Req, &old_bh->b_state);
/* Here we could run brelse or bforget. We use
bforget because it will try to put the buffer
in the freelist. */
__bforget(old_bh);
参考技术B
Linux里面block是格式化磁盘后生成的存放文件内容的东东,他的原理如下图:
js 代码 my97 日期插件 里面的onchange="chooseDate('resultid')" 是啥意思?代表啥?
麻烦大家帮帮忙。
<input type="text" name="nameddate" id="nameddate" class="textbox" onClick="WdatePicker(skin:'whyGreen',readOnly:true,dateFmt:'yyyy-MM',isShowWeek:true)" value="$namedate" onchange="chooseDate('resultid')"/>
当我点击日期界面的清空,怎么就会报错呢?
onchange是指当用onchange的网页元素的value值发生变化时调用js的chooseDate()函数
你点击清空,这时候触发了onchange 的chooseDate方法
要么你去掉onchange="chooseDate('resultid')"
要么你修改chooseDate方法 参考技术A onchange是指当用onchange的网页元素的value值发生变化时调用js的chooseDate()函数,其中resultid为函数的输入参数
以上是关于Linux里面block代表啥意思?的主要内容,如果未能解决你的问题,请参考以下文章
css里面“display=block”是啥意思?是换行吗?
谁能详细说下Linux操作系统中rpm -qagrep softname这个表达式的含义? 里面的grep代表啥意思?