linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/10] f2fs: fix negative value for lseek offset
@ 2014-09-14 22:14 Jaegeuk Kim
  2014-09-14 22:14 ` [PATCH 02/10] f2fs: remove lengthy inode->i_ino Jaegeuk Kim
                   ` (8 more replies)
  0 siblings, 9 replies; 18+ messages in thread
From: Jaegeuk Kim @ 2014-09-14 22:14 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

If application throws negative value of lseek with SEEK_DATA|SEEK_HOLE,
previous f2fs went into BUG_ON in get_dnode_of_data, which was reported
by Tommi Rantala.

He could make a simple code to detect this having:
	lseek(fd, -17595150933902LL, SEEK_DATA);

This patch should resolve that bug.

Reported-by: Tommi Rentala <tt.rantala@gmail.com>
[Jaegeuk Kim: relocate the condition as suggested by Chao]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/file.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 9f0ea3d..5cde363 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -353,6 +353,8 @@ static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
 						maxbytes, i_size_read(inode));
 	case SEEK_DATA:
 	case SEEK_HOLE:
+		if (offset < 0)
+			return -ENXIO;
 		return f2fs_seek_block(file, offset, whence);
 	}
 
-- 
1.8.5.2 (Apple Git-48)


------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk

^ permalink raw reply related	[flat|nested] 18+ messages in thread
* RE: [f2fs-dev] [PATCH 08/10] f2fs: remove redundant operation during roll-forward recovery
@ 2014-09-22  9:22 Chao Yu
  2014-09-23  5:28 ` Jaegeuk Kim
  0 siblings, 1 reply; 18+ messages in thread
From: Chao Yu @ 2014-09-22  9:22 UTC (permalink / raw)
  To: 'Jaegeuk Kim'; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Monday, September 15, 2014 6:14 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 08/10] f2fs: remove redundant operation during roll-forward recovery
> 
> If same data is updated multiple times, we don't need to redo whole the
> operations.
> Let's just update the lastest one.

Reviewed-by: Chao Yu <chao2.yu@samsung.com>

And one comment as following.

> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/f2fs.h     |  4 +++-
>  fs/f2fs/recovery.c | 41 +++++++++++++++++------------------------
>  2 files changed, 20 insertions(+), 25 deletions(-)
> 
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 48d7d46..74dde99 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -137,7 +137,9 @@ struct discard_entry {
>  struct fsync_inode_entry {
>  	struct list_head list;	/* list head */
>  	struct inode *inode;	/* vfs inode pointer */
> -	block_t blkaddr;	/* block address locating the last inode */
> +	block_t blkaddr;	/* block address locating the last fsync */
> +	block_t last_dentry;	/* block address locating the last dentry */
> +	block_t last_inode;	/* block address locating the last inode */
>  };
> 
>  #define nats_in_cursum(sum)		(le16_to_cpu(sum->n_nats))
> diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
> index 6f7fbfa..95d9dc9 100644
> --- a/fs/f2fs/recovery.c
> +++ b/fs/f2fs/recovery.c
> @@ -66,7 +66,7 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head,
>  	return NULL;
>  }
> 
> -static int recover_dentry(struct page *ipage, struct inode *inode)
> +static int recover_dentry(struct inode *inode, struct page *ipage)
>  {
>  	struct f2fs_inode *raw_inode = F2FS_INODE(ipage);
>  	nid_t pino = le32_to_cpu(raw_inode->i_pino);
> @@ -140,7 +140,7 @@ out:
>  	return err;
>  }
> 
> -static void __recover_inode(struct inode *inode, struct page *page)
> +static void recover_inode(struct inode *inode, struct page *page)
>  {
>  	struct f2fs_inode *raw = F2FS_INODE(page);
> 
> @@ -152,21 +152,9 @@ static void __recover_inode(struct inode *inode, struct page *page)
>  	inode->i_atime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec);
>  	inode->i_ctime.tv_nsec = le32_to_cpu(raw->i_ctime_nsec);
>  	inode->i_mtime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec);
> -}
> -
> -static int recover_inode(struct inode *inode, struct page *node_page)
> -{
> -	if (!IS_INODE(node_page))
> -		return 0;
> -
> -	__recover_inode(inode, node_page);
> -
> -	if (is_dent_dnode(node_page))
> -		return recover_dentry(node_page, inode);
> 
>  	f2fs_msg(inode->i_sb, KERN_NOTICE, "recover_inode: ino = %x, name = %s",
> -			ino_of_node(node_page), F2FS_INODE(node_page)->i_name);
> -	return 0;
> +			ino_of_node(page), F2FS_INODE(page)->i_name);
>  }
> 
>  static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
> @@ -214,12 +202,11 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head
> *head)
>  			}
> 
>  			/* add this fsync inode to the list */
> -			entry = kmem_cache_alloc(fsync_entry_slab, GFP_NOFS);
> +			entry = kmem_cache_alloc(fsync_entry_slab, GFP_F2FS_ZERO);
>  			if (!entry) {
>  				err = -ENOMEM;
>  				break;
>  			}
> -
>  			/*
>  			 * CP | dnode(F) | inode(DF)
>  			 * For this case, we should not give up now.
> @@ -236,9 +223,11 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head
> *head)
>  		}
>  		entry->blkaddr = blkaddr;
> 
> -		err = recover_inode(entry->inode, page);
> -		if (err && err != -ENOENT)
> -			break;
> +		if (IS_INODE(page)) {
> +			entry->last_inode = blkaddr;
> +			if (is_dent_dnode(page))
> +				entry->last_dentry = blkaddr;
> +		}
>  next:
>  		/* check next segment */
>  		blkaddr = next_blkaddr_of_node(page);
> @@ -455,11 +444,15 @@ static int recover_data(struct f2fs_sb_info *sbi,
>  		/*
>  		 * inode(x) | CP | inode(x) | dnode(F)
>  		 * In this case, we can lose the latest inode(x).
> -		 * So, call __recover_inode for the inode update.
> +		 * So, call recover_inode for the inode update.
>  		 */
> -		if (IS_INODE(page))
> -			__recover_inode(entry->inode, page);
> -
> +		if (entry->last_inode == blkaddr)
> +			recover_inode(entry->inode, page);
> +		if (entry->last_dentry == blkaddr) {
> +			err = recover_dentry(entry->inode, page);
> +			if (err)

Need f2fs_put_page(page, 1);

> +				break;
> +		}
>  		err = do_recover_data(sbi, entry->inode, page, blkaddr);
>  		if (err)
>  			break;
> --
> 1.8.5.2 (Apple Git-48)
> 
> 
> ------------------------------------------------------------------------------
> Want excitement?
> Manually upgrade your production database.
> When you want reliability, choose Perforce
> Perforce version control. Predictably reliable.
> http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-09-23  6:54 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-14 22:14 [PATCH 01/10] f2fs: fix negative value for lseek offset Jaegeuk Kim
2014-09-14 22:14 ` [PATCH 02/10] f2fs: remove lengthy inode->i_ino Jaegeuk Kim
2014-09-14 22:14 ` [PATCH 03/10] f2fs: expand counting dirty pages in the inode page cache Jaegeuk Kim
2014-09-14 22:14 ` [PATCH 04/10] f2fs: give an option to enable in-place-updates during fsync to users Jaegeuk Kim
2014-09-15  2:13   ` [f2fs-dev] " Changman Lee
2014-09-18  5:39     ` Jaegeuk Kim
2014-09-14 22:14 ` [PATCH 05/10] f2fs: fix roll-forward missing scenarios Jaegeuk Kim
2014-09-14 22:14 ` [PATCH 06/10] f2fs: do not skip latest inode information Jaegeuk Kim
2014-09-14 22:14 ` [PATCH 07/10] f2fs: use meta_inode cache to improve roll-forward speed Jaegeuk Kim
2014-09-22  2:36   ` [f2fs-dev] " Chao Yu
2014-09-23  4:46     ` Jaegeuk Kim
2014-09-23  6:54       ` [f2fs-dev] " Chao Yu
2014-09-14 22:14 ` [PATCH 08/10] f2fs: remove redundant operation during roll-forward recovery Jaegeuk Kim
2014-09-14 22:14 ` [PATCH 09/10] f2fs: use MAX_BIO_BLOCKS(sbi) Jaegeuk Kim
2014-09-14 22:34   ` Joe Perches
2014-09-18  5:37     ` Jaegeuk Kim
2014-09-14 22:14 ` [PATCH 10/10] f2fs: fix double lock for inode page during roll-foward recovery Jaegeuk Kim
  -- strict thread matches above, loose matches on Subject: below --
2014-09-22  9:22 [f2fs-dev] [PATCH 08/10] f2fs: remove redundant operation during roll-forward recovery Chao Yu
2014-09-23  5:28 ` Jaegeuk Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).