⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 028_bad_inode_c.html

📁 重读linux 2.4.2o所写的笔记
💻 HTML
字号:
  <html lang="zh-CN" xmlns:gdoc="">  <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <style type="text/css">/* default css */table {  font-size: 1em;  line-height: inherit;}div, address, ol, ul, li, option, select {   margin-top: 0px;  margin-bottom: 0px;}p {  margin: 0px;}body {        margin: 0px;          padding: 0px;    font-family: Verdana, sans-serif;  font-size: 10pt;  background-color: #ffffff;}h6 { font-size: 10pt }h5 { font-size: 11pt }h4 { font-size: 12pt }h3 { font-size: 13pt }h2 { font-size: 14pt }h1 { font-size: 16pt }blockquote {padding: 10px; border: 1px #DDD dashed }a img {border: 0}div.google_header, div.google_footer {  position: relative;  margin-top: 1em;  margin-bottom: 1em;}/* end default css */  /* default print css */    @media print {    body {       padding: 0;       margin: 0;     }    div.google_header, div.google_footer {      display: block;      min-height: 0;      border: none;    }    div.google_header {      flow: static(header);    }    /* used to insert page numbers */    div.google_header::before, div.google_footer::before {      position: absolute;      top: 0;    }    div.google_footer {      flow: static(footer);    }    /* always consider this element at the start of the doc */    div#google_footer {      flow: static(footer, start);    }    span.google_pagenumber {      content: counter(page);    }    span.google_pagecount {      content: counter(pages);    }  }  @page {    @top {      content: flow(header);    }    @bottom {      content: flow(footer);    }  }  /* end default print css */ /* custom css *//* end custom css */  /* ui edited css */    body {    font-family: Verdana;        font-size: 10.0pt;    line-height: normal;    background-color: #ffffff;  }    .documentBG {    background-color: #ffffff;  }  /* end ui edited css */</style>   </head>  <body  revision="dcbsxfpf_9cn4gd8:3">      <table align=center cellpadding=0 cellspacing=0 height=5716 width=802>
  <tbody>
  <tr>
    <td height=5716 valign=top width=802>
      <pre>2007-3-16</pre>
      <pre>   <span lang=zh-cn>当系统发现一个文件的inode有错误的时候,不是返回一个NULL指针,而是返回一个bad_inode.此inode的所有操作函数都返回-EIO.<br>此模块的主要对外接口是</span></pre>
      <pre><font color=#0000ff>/*<br> * When a filesystem is unable to read an inode due to an I/O error in<br> * its read_inode() function, it can call make_bad_inode() to return a<br> * set of stubs which will return EIO errors as required. <br> *<br> * We only need to do limited initialisation: all other fields are<br> * preinitialised to zero automatically.<br> */<br> </font></pre>
      <pre><font color=#0000ff>/**<br> *	make_bad_inode - mark an inode bad due to an I/O error<br> *	@inode: Inode to mark bad<br> *<br> *	When an inode cannot be read due to a media or remote network<br> *	failure this function makes the inode "bad" and causes I/O operations<br> *	on it to fail from this point on.<br> */</font>
 </pre>
      <pre>void <b><font color=#008080>make_bad_inode</font></b>(struct inode * inode) <br>{<br>	inode-&gt;i_mode = S_IFREG;<br>	inode-&gt;i_atime = inode-&gt;i_mtime = inode-&gt;i_ctime = CURRENT_TIME;<br>	inode-&gt;i_op = &amp;bad_inode_ops;	<br>	inode-&gt;i_fop = &amp;bad_file_ops;	<br>}</pre>
      <pre><font color=#0000ff>/*<br> * This tests whether an inode has been flagged as bad. The test uses<br> * &amp;bad_inode_ops to cover the case of invalidated inodes as well as<br> * those created by make_bad_inode() above.<br> */<br> </font></pre>
      <pre><font color=#0000ff>/**<br> *	is_bad_inode - is an inode errored<br> *	@inode: inode to test<br> *<br> *	Returns true if the inode in question has been marked as bad.<br> */<br> </font></pre>
      <pre>int <font color=#008080><b>is_bad_inode</b></font>(struct inode * inode) <br>{<br>	return (inode-&gt;i_op == &amp;bad_inode_ops);	<br>}</pre>
      <pre>   这是个很好的例子,证名文件操作函数来自于对应的inode。so simple。唯独<font color=#008080><b>bad_follow_link</b></font>需要一些操作:</pre>
      <pre><font color=#0000ff>/*<br>* The follow_link operation is special: it must behave as a no-op<br>* so that a bad root inode can at least be unmounted. To do this<br>* we must dput() the base and return the dentry with a dget().<br>*/</font>
static int <font color=#008080><b>bad_follow_link</b></font>(struct dentry *dent, struct nameidata *nd)<br>{<br>dput(nd-&gt;dentry);<br>nd-&gt;dentry = dget(dent);<br>return 0;<br>}</pre>
      <pre><span lang=zh-cn>   可以想象,当初为了能让bad inode可以unmout,这里进行过艰苦的调试。可惜,到后来的版本中,不能unmout bad inode的情况依<br>然存在。这个函数又被删除。看看path_walk,当inode-&gt;fllow_link 为非指针的时候,inode被认为是一个link。不必深究了,这里要做<br>的很简单,只要没有什么问题即可。只是要关注一下bad inode 的umount问题。</span></pre>
      <pre> </pre>
      <pre> </pre>
      <pre>   <br></pre>
    </td>
  </tr>
  </tbody>
</table></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -