Thread (8 messages) 8 messages, 3 authors, 2012-08-21

Re: [PATCH v7 2/4] xfs: Introduce a helper routine to probe data or hole offset from page cache

From: Dave Chinner <david@fromorbit.com>
Date: 2012-08-20 23:13:44

On Mon, Aug 13, 2012 at 09:07:58PM +0800, Jeff Liu wrote:
helper routine to lookup data or hole offset from page cache for unwritten extents.

Signed-off-by: Jie Liu <redacted>
....
+		unsigned int	i;
+
+		want = min_t(pgoff_t, end - index, (pgoff_t)PAGEVEC_SIZE);
No need for the cast to (pgoff_t) here. That's what the min_t()
macro does for you.
+		for (i = 0; i < nr_pages; i++) {
+			struct page	*page = pvec.pages[i];
+			loff_t		b_offset;
+
+			/*
+			 * Page index is out of range, searching done.
+			 * If the current offset is not reaches the end
+			 * of the specified search range, there should
+			 * be a hole between them.
+			 */
+			if (page->index > end) {
+				if (type == HOLE_OFF && lastoff < endoff) {
+					*offset = lastoff;
+					found = true;
+				}
+				goto out;
+			}
+
+			lock_page(page);
+			/*
+			 * Page truncated or invalidated(page->mapping == NULL).
+			 * We can freely skip it and proceed to check the next
+			 * page.
+			 */
+			if (unlikely(page->mapping != inode->i_mapping)) {
+				unlock_page(page);
+				continue;
+			}
Still need to check page->index again after locking the page. As
this isn't performance critical, I don't think you need the check
before the page is locked, anyway....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help