xfs
[Top] [All Lists]

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

To: jeff.liu@xxxxxxxxxx
Subject: Re: [PATCH v7 2/4] xfs: Introduce a helper routine to probe data or hole offset from page cache
From: Mark Tinguely <tinguely@xxxxxxx>
Date: Mon, 20 Aug 2012 10:31:11 -0500
Cc: xfs@xxxxxxxxxxx
In-reply-to: <5028FC2E.2010802@xxxxxxxxxx>
References: <5028FC2E.2010802@xxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:9.0) Gecko/20120122 Thunderbird/9.0
On 08/13/12 08:07, Jeff Liu wrote:
helper routine to lookup data or hole offset from page cache for unwritten 
extents.

Signed-off-by: Jie Liu<jeff.liu@xxxxxxxxxx>

---
  fs/xfs/xfs_file.c |  213 +++++++++++++++++++++++++++++++++++++++++++++++++++++
  1 files changed, 213 insertions(+), 0 deletions(-)
+STATIC bool
+xfs_find_get_desired_pgoff(
+       struct inode            *inode,
+       struct xfs_bmbt_irec    *map,
+       unsigned int            type,
+       loff_t                  *offset)
+{

...

+               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) {

Shouldn't this sample of the index also be locked?

+                               if (type == HOLE_OFF&&  lastoff<  endoff) {
+                                       *offset = lastoff;
+                                       found = true;
+                               }
+                               goto out;
+                       }
+
+                       lock_page(page);

--Mark.

<Prev in Thread] Current Thread [Next in Thread>