Skip to content

Commit

Permalink
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/jaegeuk/f2fs

Pull f2fs bug fixes from Jaegeuk Kim:
 "This patch-set includes two major bug fixes:
   - incorrect IUsed provided by *df -i*, and
   - lookup failure of parent inodes in corner cases.

  [Other Bug Fixes]
   - Fix error handling routines
   - Trigger recovery process correctly
   - Resolve build failures due to missing header files

  [Etc]
   - Add a MAINTAINERS entry for f2fs
   - Fix and clean up variables, functions, and equations
   - Avoid warnings during compilation"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs:
  f2fs: unify string length declarations and usage
  f2fs: clean up unused variables and return values
  f2fs: clean up the start_bidx_of_node function
  f2fs: remove unneeded variable from f2fs_sync_fs
  f2fs: fix fsync_inode list addition logic and avoid invalid access to memory
  f2fs: remove unneeded initialization of nr_dirty in dirty_seglist_info
  f2fs: handle error from f2fs_iget_nowait
  f2fs: fix equation of has_not_enough_free_secs()
  f2fs: add MAINTAINERS entry
  f2fs: return a default value for non-void function
  f2fs: invalidate the node page if allocation is failed
  f2fs: add missing #include <linux/prefetch.h>
  f2fs: do f2fs_balance_fs in front of dir operations
  f2fs: should recover orphan and fsync data
  f2fs: fix handling errors got by f2fs_write_inode
  f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number
  f2fs: fix wrong calculation on f_files in statfs
  f2fs: remove set_page_dirty for atomic f2fs_end_io_write
  • Loading branch information
torvalds committed Jan 3, 2013
2 parents ed4e6a9 + 9836b8b commit 2318aa2
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 137 deletions.
10 changes: 10 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -3273,6 +3273,16 @@ F: Documentation/filesystems/caching/
F: fs/fscache/
F: include/linux/fscache*.h

F2FS FILE SYSTEM
M: Jaegeuk Kim <[email protected]>
L: [email protected]
W: http://en.wikipedia.org/wiki/F2FS
T: git git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git
S: Maintained
F: Documentation/filesystems/f2fs.txt
F: fs/f2fs/
F: include/linux/f2fs_fs.h

FUJITSU FR-V (FRV) PORT
M: David Howells <[email protected]>
S: Maintained
Expand Down
1 change: 1 addition & 0 deletions fs/f2fs/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/backing-dev.h>
#include <linux/blkdev.h>
#include <linux/bio.h>
#include <linux/prefetch.h>

#include "f2fs.h"
#include "node.h"
Expand Down
16 changes: 9 additions & 7 deletions fs/f2fs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <linux/fs.h>
#include <linux/f2fs_fs.h>
#include "f2fs.h"
#include "node.h"
#include "acl.h"

static unsigned long dir_blocks(struct inode *inode)
Expand Down Expand Up @@ -74,7 +75,7 @@ static unsigned long dir_block_index(unsigned int level, unsigned int idx)
return bidx;
}

static bool early_match_name(const char *name, int namelen,
static bool early_match_name(const char *name, size_t namelen,
f2fs_hash_t namehash, struct f2fs_dir_entry *de)
{
if (le16_to_cpu(de->name_len) != namelen)
Expand All @@ -87,7 +88,7 @@ static bool early_match_name(const char *name, int namelen,
}

static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
const char *name, int namelen, int *max_slots,
const char *name, size_t namelen, int *max_slots,
f2fs_hash_t namehash, struct page **res_page)
{
struct f2fs_dir_entry *de;
Expand Down Expand Up @@ -126,7 +127,7 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
}

static struct f2fs_dir_entry *find_in_level(struct inode *dir,
unsigned int level, const char *name, int namelen,
unsigned int level, const char *name, size_t namelen,
f2fs_hash_t namehash, struct page **res_page)
{
int s = GET_DENTRY_SLOTS(namelen);
Expand Down Expand Up @@ -181,7 +182,7 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,
struct qstr *child, struct page **res_page)
{
const char *name = child->name;
int namelen = child->len;
size_t namelen = child->len;
unsigned long npages = dir_blocks(dir);
struct f2fs_dir_entry *de = NULL;
f2fs_hash_t name_hash;
Expand Down Expand Up @@ -308,6 +309,7 @@ static int init_inode_metadata(struct inode *inode, struct dentry *dentry)
ipage = get_node_page(F2FS_SB(dir->i_sb), inode->i_ino);
if (IS_ERR(ipage))
return PTR_ERR(ipage);
set_cold_node(inode, ipage);
init_dent_inode(dentry, ipage);
f2fs_put_page(ipage, 1);
}
Expand Down Expand Up @@ -381,7 +383,7 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode)
struct inode *dir = dentry->d_parent->d_inode;
struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
const char *name = dentry->d_name.name;
int namelen = dentry->d_name.len;
size_t namelen = dentry->d_name.len;
struct page *dentry_page = NULL;
struct f2fs_dentry_block *dentry_blk = NULL;
int slots = GET_DENTRY_SLOTS(namelen);
Expand Down Expand Up @@ -540,13 +542,13 @@ int f2fs_make_empty(struct inode *inode, struct inode *parent)

de = &dentry_blk->dentry[0];
de->name_len = cpu_to_le16(1);
de->hash_code = 0;
de->hash_code = f2fs_dentry_hash(".", 1);
de->ino = cpu_to_le32(inode->i_ino);
memcpy(dentry_blk->filename[0], ".", 1);
set_de_type(de, inode);

de = &dentry_blk->dentry[1];
de->hash_code = 0;
de->hash_code = f2fs_dentry_hash("..", 2);
de->name_len = cpu_to_le16(2);
de->ino = cpu_to_le32(parent->i_ino);
memcpy(dentry_blk->filename[1], "..", 2);
Expand Down
2 changes: 1 addition & 1 deletion fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ int f2fs_sync_fs(struct super_block *, int);
/*
* hash.c
*/
f2fs_hash_t f2fs_dentry_hash(const char *, int);
f2fs_hash_t f2fs_dentry_hash(const char *, size_t);

/*
* node.c
Expand Down
10 changes: 6 additions & 4 deletions fs/f2fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,17 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
if (need_to_sync_dir(sbi, inode))
need_cp = true;

f2fs_write_inode(inode, NULL);

if (need_cp) {
/* all the dirty node pages should be flushed for POR */
ret = f2fs_sync_fs(inode->i_sb, 1);
clear_inode_flag(F2FS_I(inode), FI_NEED_CP);
} else {
while (sync_node_pages(sbi, inode->i_ino, &wbc) == 0)
f2fs_write_inode(inode, NULL);
/* if there is no written node page, write its inode page */
while (!sync_node_pages(sbi, inode->i_ino, &wbc)) {
ret = f2fs_write_inode(inode, NULL);
if (ret)
goto out;
}
filemap_fdatawait_range(sbi->node_inode->i_mapping,
0, LONG_MAX);
}
Expand Down
34 changes: 11 additions & 23 deletions fs/f2fs/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,7 @@ static int gc_node_segment(struct f2fs_sb_info *sbi,
}

err = check_valid_map(sbi, segno, off);
if (err == GC_ERROR)
return err;
else if (err == GC_NEXT)
if (err == GC_NEXT)
continue;

if (initial) {
Expand Down Expand Up @@ -430,28 +428,22 @@ static int gc_node_segment(struct f2fs_sb_info *sbi,
*/
block_t start_bidx_of_node(unsigned int node_ofs)
{
block_t start_bidx;
unsigned int bidx, indirect_blks;
int dec;
unsigned int indirect_blks = 2 * NIDS_PER_BLOCK + 4;
unsigned int bidx;

indirect_blks = 2 * NIDS_PER_BLOCK + 4;
if (node_ofs == 0)
return 0;

start_bidx = 1;
if (node_ofs == 0) {
start_bidx = 0;
} else if (node_ofs <= 2) {
if (node_ofs <= 2) {
bidx = node_ofs - 1;
} else if (node_ofs <= indirect_blks) {
dec = (node_ofs - 4) / (NIDS_PER_BLOCK + 1);
int dec = (node_ofs - 4) / (NIDS_PER_BLOCK + 1);
bidx = node_ofs - 2 - dec;
} else {
dec = (node_ofs - indirect_blks - 3) / (NIDS_PER_BLOCK + 1);
int dec = (node_ofs - indirect_blks - 3) / (NIDS_PER_BLOCK + 1);
bidx = node_ofs - 5 - dec;
}

if (start_bidx)
start_bidx = bidx * ADDRS_PER_BLOCK + ADDRS_PER_INODE;
return start_bidx;
return bidx * ADDRS_PER_BLOCK + ADDRS_PER_INODE;
}

static int check_dnode(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
Expand Down Expand Up @@ -556,9 +548,7 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
}

err = check_valid_map(sbi, segno, off);
if (err == GC_ERROR)
goto stop;
else if (err == GC_NEXT)
if (err == GC_NEXT)
continue;

if (phase == 0) {
Expand All @@ -568,9 +558,7 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,

/* Get an inode by ino with checking validity */
err = check_dnode(sbi, entry, &dni, start_addr + off, &nofs);
if (err == GC_ERROR)
goto stop;
else if (err == GC_NEXT)
if (err == GC_NEXT)
continue;

if (phase == 1) {
Expand Down
18 changes: 11 additions & 7 deletions fs/f2fs/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static void TEA_transform(unsigned int buf[4], unsigned int const in[])
buf[1] += b1;
}

static void str2hashbuf(const char *msg, int len, unsigned int *buf, int num)
static void str2hashbuf(const char *msg, size_t len, unsigned int *buf, int num)
{
unsigned pad, val;
int i;
Expand All @@ -69,29 +69,33 @@ static void str2hashbuf(const char *msg, int len, unsigned int *buf, int num)
*buf++ = pad;
}

f2fs_hash_t f2fs_dentry_hash(const char *name, int len)
f2fs_hash_t f2fs_dentry_hash(const char *name, size_t len)
{
__u32 hash, minor_hash;
__u32 hash;
f2fs_hash_t f2fs_hash;
const char *p;
__u32 in[8], buf[4];

if ((len <= 2) && (name[0] == '.') &&
(name[1] == '.' || name[1] == '\0'))
return 0;

/* Initialize the default seed for the hash checksum functions */
buf[0] = 0x67452301;
buf[1] = 0xefcdab89;
buf[2] = 0x98badcfe;
buf[3] = 0x10325476;

p = name;
while (len > 0) {
while (1) {
str2hashbuf(p, len, in, 4);
TEA_transform(buf, in);
len -= 16;
p += 16;
if (len <= 16)
break;
len -= 16;
}
hash = buf[0];
minor_hash = buf[1];

f2fs_hash = cpu_to_le32(hash & ~F2FS_HASH_COL_BIT);
return f2fs_hash;
}
1 change: 1 addition & 0 deletions fs/f2fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ void update_inode(struct inode *inode, struct page *node_page)
ri->i_flags = cpu_to_le32(F2FS_I(inode)->i_flags);
ri->i_pino = cpu_to_le32(F2FS_I(inode)->i_pino);
ri->i_generation = cpu_to_le32(inode->i_generation);
set_cold_node(inode, node_page);
set_page_dirty(node_page);
}

Expand Down
Loading

0 comments on commit 2318aa2

Please sign in to comment.