原来从来没有清楚的描述出write函数在传递到内核中的缓冲页,如果刷新缓冲页失败,数据将会如何处理,是否会一直保存在内存中,耗尽内存的空间??
获取错误码:
static void handle_write_error(struct address_space *mapping, struct page *page, int error) { lock_page(page); if (page_mapping(page) == mapping) { if (error == -ENOSPC) set_bit(AS_ENOSPC, &mapping->flags); else set_bit(AS_EIO, &mapping->flags); } unlock_page(page); }
在linux 源码中找到的资料不多:
/* * Bits in mapping->flags. The lower __GFP_BITS_SHIFT bits are the page * allocation mode flags. */ #define AS_EIO (__GFP_BITS_SHIFT + 0) /* IO error on async write */ #define AS_ENOSPC (__GFP_BITS_SHIFT + 1) /* ENOSPC on async write */
仔细检查了一下读写的方式:
/*
* ->writepage() return values (make these much larger than a pagesize, in
* case some fs is returning number-of-bytes-written from writepage)
*/
#define WRITEPAGE_ACTIVATE 0x80000 /* IO was not started: activate page */
时间: 2024-11-05 13:40:43