Re: [Linux-NTFS-Dev] 2.6.23 regression: second access of empty ntfs file leads to D state hang

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Anton Altaparmakov <aia21@...>
Cc: LKML <linux-kernel@...>, ntfs-dev <linux-ntfs-dev@...>, Neil Brown <neilb@...>
Date: Saturday, November 3, 2007 - 12:56 am

On Fri, 2007-11-02 at 19:22 +0000, Anton Altaparmakov wrote:


Modulo uninitialized vi, works fine.  I moved it up, and all is well.
Thanks.

Tested-by:  Mike Galbraith <efault@gmx.de>

diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index cfdc790..ad87cb0 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -405,6 +405,15 @@ static int ntfs_readpage(struct file *file, struct page *page)
 
 retry_readpage:
 	BUG_ON(!PageLocked(page));
+	vi = page->mapping->host;
+	i_size = i_size_read(vi);
+	/* Is the page fully outside i_size? (truncate in progress) */
+	if (unlikely(page->index >= (i_size + PAGE_CACHE_SIZE - 1) >>
+			PAGE_CACHE_SHIFT)) {
+		zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
+		ntfs_debug("Read outside i_size - truncated?");
+		goto done;
+	}
 	/*
 	 * This can potentially happen because we clear PageUptodate() during
 	 * ntfs_writepage() of MstProtected() attributes.
@@ -413,7 +422,6 @@ retry_readpage:
 		unlock_page(page);
 		return 0;
 	}
-	vi = page->mapping->host;
 	ni = NTFS_I(vi);
 	/*
 	 * Only $DATA attributes can be encrypted and only unnamed $DATA
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index 92dabdc..50d3b0c 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -179,10 +179,7 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, ntfs_attr_search_ctx *ctx)
 	 * ntfs_mapping_pairs_decompress() fails.
 	 */
 	end_vcn = sle64_to_cpu(a->data.non_resident.highest_vcn) + 1;
-	if (!a->data.non_resident.lowest_vcn && end_vcn == 1)
-		end_vcn = sle64_to_cpu(a->data.non_resident.allocated_size) >>
-				ni->vol->cluster_size_bits;
-	if (unlikely(vcn >= end_vcn)) {
+	if (unlikely(vcn && vcn >= end_vcn)) {
 		err = -ENOENT;
 		goto err_out;
 	}
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
index d98daf5..d1619d0 100644
--- a/fs/ntfs/compress.c
+++ b/fs/ntfs/compress.c
@@ -561,6 +561,16 @@ int ntfs_read_compressed_block(struct page *page)
 	read_unlock_irqrestore(&ni->size_lock, flags);
 	max_page = ((i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT) -
 			offset;
+	/* Is the page fully outside i_size? (truncate in progress) */
+	if (xpage >= max_page) {
+		kfree(bhs);
+		kfree(pages);
+		zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
+		ntfs_debug("Compressed read outside i_size - truncated?");
+		SetPageUptodate(page);
+		unlock_page(page);
+		return 0;
+	}
 	if (nr_pages < max_page)
 		max_page = nr_pages;
 	for (i = 0; i < max_page; i++, offset++) {


-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [Linux-NTFS-Dev] 2.6.23 regression: second access of emp..., Anton Altaparmakov, (Mon Oct 29, 6:31 am)
Re: [Linux-NTFS-Dev] 2.6.23 regression: second access of emp..., Anton Altaparmakov, (Mon Oct 29, 9:39 am)
Re: [Linux-NTFS-Dev] 2.6.23 regression: second access of emp..., Anton Altaparmakov, (Tue Oct 30, 5:23 am)
Re: [Linux-NTFS-Dev] 2.6.23 regression: second access of emp..., Anton Altaparmakov, (Fri Nov 2, 3:22 pm)
Re: [Linux-NTFS-Dev] 2.6.23 regression: second access of emp..., Mike Galbraith, (Sat Nov 3, 12:56 am)
Re: [Linux-NTFS-Dev] 2.6.23 regression: second access of emp..., Anton Altaparmakov, (Sat Nov 3, 3:27 am)
Re: [Linux-NTFS-Dev] 2.6.23 regression: second access of emp..., Anton Altaparmakov, (Mon Oct 29, 9:41 am)
Re: 2.6.23 regression: second access of empty ntfs file lead..., Anton Altaparmakov, (Mon Oct 29, 6:40 am)