URN Logo
UNIX Resources » Linux » China Linux Forum » Linux内核技术 » 18 » 重读2.4 --028 fs/bad_inode.c
announcement 声明: 本页内容为中国Linux论坛的内容镜像,文章的版权以及其他所有的相关权利属于中国Linux论坛和相应文章的作者,如果转载,请注明文章来源及相关版权信息。
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.net
  业界新闻与评论
  自由软件杂谈
  IT 人生
  Linux软件快递
  翻译作坊
  Linux图书与评论
  GNU Emacs/XEmacs
  Linux 中文环境和中文化
  Linux桌面与办公软件
  Linux 多媒体与娱乐版
  自由之窗Mozilla
  笔记本电脑上的Linux
  Gentoo
  Debian 一族
  网络管理技术
  Linux 安装与入门
  WEB服务器和FTP服务器
  域名服务器和邮件服务器
  Linux防火墙和代理服务器应用
  文件及打印服务器
  技术培训与认证
  TI专版
  Linux内核技术
  Linux 嵌入技术
  Linux设备驱动程序
  Linux 集群技术
  LINUX平台数据库
  系统和网络安全
  CPU 与 编译器
  系统计算研究所专栏
  Linux下的GUI软件开发
  C/C++编程版
  PHP 技 术
  Java&jsp技术
  Shell编程技术
  Perl 编 程
  Python 编 程
  XML/Web Service 技术
  永远的Unix
  FreeBSD世界
   
重读2.4 --028 fs/bad_inode.c
Author: hyl    Posted: 2007-11-13 21:06    Length: 3,002 byte(s)
[Original] [Print] [Top]

2007-3-16


当系统发现一个文件的inode有错误的时候,不是返回一个NULL指针,而是返回一个bad_inode.此i
node的所有操作函数都返回-EIO.
此模块的主要对外接口是

/*
* When a filesystem is unable to read an inode due to an I/O error in
* its read_inode() function, it can call make_bad_inode() to return a
* set of stubs which will return EIO errors as required.
*
* We only need to do limited initialisation: all other fields are
* preinitialised to zero automatically.
*/


/**
* make_bad_inode - mark an inode bad due to an I/O error
* @inode: Inode to mark bad
*
* When an inode cannot be read due to a media or remote network
* failure this function makes the inode "bad" and causes I/O operations
* on it to fail from this point on.
*/


void make_bad_inode(struct inode * inode)
{
inode->i_mode = S_IFREG;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_op = &bad_inode_ops;
inode->i_fop = &bad_file_ops;
}

/*
* This tests whether an inode has been flagged as bad. The test uses
* &bad_inode_ops to cover the case of invalidated inodes as well as
* those created by make_bad_inode() above.
*/


/**
* is_bad_inode - is an inode errored
* @inode: inode to test
*
* Returns true if the inode in question has been marked as bad.
*/


int is_bad_inode(struct inode * inode)
{
return (inode->i_op == &bad_inode_ops);
}

这是个很好的例子,证名文件操作函数来自于对应的inode。so
simple。唯独bad_follow_link需要一些操作:

/*
* The follow_link operation is special: it must behave as a no-op
* so that a bad root inode can at least be unmounted. To do this
* we must dput() the base and return the dentry with a dget().
*/
static int bad_follow_link(struct dentry *dent, struct nameidata *nd)
{
dput(nd->dentry);
nd->dentry = dget(dent);
return 0;
}

可以想象,当初为了能让bad
inode可以unmout,这里进行过艰苦的调试。可惜,到后来的版本中,不能unmout bad
inode的情况依
然存在。这个函数又被删除。看看path_walk,当inode->fllow_link
为非指针的时候,inode被认为是一个link。不必深究了,这里要做
的很简单,只要没有什么问题即可。只是要关注一下bad inode 的umount问题。

 

 

[Original] [Print] [Top]
« Previous thread
求救:内核netlink接收问题!!
Linux内核技术
18
Next thread »
重读2.4 --027 fs/attr.c dnotify.c
     

Copyright © 2007~2009 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
webmaster: webmaster@unixresources.net
This page created on 2009-09-07 16:26:33, cost 0.0185520648956 ms.