segment.c (239060b93bb30a4ad55f1ecaa512464a035cc5ba) | segment.c (6c43f41000312fefa482c3bfdd97e7f81d6be0ec) |
---|---|
1/* 2 * segment.c - NILFS segment constructor. 3 * 4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 352 unchanged lines hidden (view full) --- 361 struct nilfs_segment_buffer *segbuf = sci->sc_curseg; 362 struct buffer_head *sumbh; 363 unsigned sumbytes; 364 unsigned flags = 0; 365 int err; 366 367 if (nilfs_doing_gc()) 368 flags = NILFS_SS_GC; | 1/* 2 * segment.c - NILFS segment constructor. 3 * 4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 352 unchanged lines hidden (view full) --- 361 struct nilfs_segment_buffer *segbuf = sci->sc_curseg; 362 struct buffer_head *sumbh; 363 unsigned sumbytes; 364 unsigned flags = 0; 365 int err; 366 367 if (nilfs_doing_gc()) 368 flags = NILFS_SS_GC; |
369 err = nilfs_segbuf_reset(segbuf, flags, sci->sc_seg_ctime, 370 sci->sc_sbi->s_nilfs->ns_cno); | 369 err = nilfs_segbuf_reset(segbuf, flags, sci->sc_seg_ctime, sci->sc_cno); |
371 if (unlikely(err)) 372 return err; 373 374 sumbh = NILFS_SEGBUF_FIRST_BH(&segbuf->sb_segsum_buffers); 375 sumbytes = segbuf->sb_sum.sumbytes; 376 sci->sc_finfo_ptr.bh = sumbh; sci->sc_finfo_ptr.offset = sumbytes; 377 sci->sc_binfo_ptr.bh = sumbh; sci->sc_binfo_ptr.offset = sumbytes; 378 sci->sc_blk_cnt = sci->sc_datablk_cnt = 0; --- 56 unchanged lines hidden (view full) --- 435} 436 437static void nilfs_segctor_end_finfo(struct nilfs_sc_info *sci, 438 struct inode *inode) 439{ 440 struct nilfs_finfo *finfo; 441 struct nilfs_inode_info *ii; 442 struct nilfs_segment_buffer *segbuf; | 370 if (unlikely(err)) 371 return err; 372 373 sumbh = NILFS_SEGBUF_FIRST_BH(&segbuf->sb_segsum_buffers); 374 sumbytes = segbuf->sb_sum.sumbytes; 375 sci->sc_finfo_ptr.bh = sumbh; sci->sc_finfo_ptr.offset = sumbytes; 376 sci->sc_binfo_ptr.bh = sumbh; sci->sc_binfo_ptr.offset = sumbytes; 377 sci->sc_blk_cnt = sci->sc_datablk_cnt = 0; --- 56 unchanged lines hidden (view full) --- 434} 435 436static void nilfs_segctor_end_finfo(struct nilfs_sc_info *sci, 437 struct inode *inode) 438{ 439 struct nilfs_finfo *finfo; 440 struct nilfs_inode_info *ii; 441 struct nilfs_segment_buffer *segbuf; |
442 __u64 cno; |
|
443 444 if (sci->sc_blk_cnt == 0) 445 return; 446 447 ii = NILFS_I(inode); | 443 444 if (sci->sc_blk_cnt == 0) 445 return; 446 447 ii = NILFS_I(inode); |
448 449 if (test_bit(NILFS_I_GCINODE, &ii->i_state)) 450 cno = ii->i_cno; 451 else if (NILFS_ROOT_METADATA_FILE(inode->i_ino)) 452 cno = 0; 453 else 454 cno = sci->sc_cno; 455 |
|
448 finfo = nilfs_segctor_map_segsum_entry(sci, &sci->sc_finfo_ptr, 449 sizeof(*finfo)); 450 finfo->fi_ino = cpu_to_le64(inode->i_ino); 451 finfo->fi_nblocks = cpu_to_le32(sci->sc_blk_cnt); 452 finfo->fi_ndatablk = cpu_to_le32(sci->sc_datablk_cnt); | 456 finfo = nilfs_segctor_map_segsum_entry(sci, &sci->sc_finfo_ptr, 457 sizeof(*finfo)); 458 finfo->fi_ino = cpu_to_le64(inode->i_ino); 459 finfo->fi_nblocks = cpu_to_le32(sci->sc_blk_cnt); 460 finfo->fi_ndatablk = cpu_to_le32(sci->sc_datablk_cnt); |
453 finfo->fi_cno = cpu_to_le64(ii->i_cno); | 461 finfo->fi_cno = cpu_to_le64(cno); |
454 455 segbuf = sci->sc_curseg; 456 segbuf->sb_sum.sumbytes = sci->sc_binfo_ptr.offset + 457 sci->sc_super->s_blocksize * (segbuf->sb_sum.nsumblk - 1); 458 sci->sc_finfo_ptr = sci->sc_binfo_ptr; 459 sci->sc_blk_cnt = sci->sc_datablk_cnt = 0; 460} 461 --- 1509 unchanged lines hidden (view full) --- 1971 } 1972 return ret; 1973} 1974 1975static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, 1976 struct nilfs_sb_info *sbi) 1977{ 1978 struct nilfs_inode_info *ii, *n; | 462 463 segbuf = sci->sc_curseg; 464 segbuf->sb_sum.sumbytes = sci->sc_binfo_ptr.offset + 465 sci->sc_super->s_blocksize * (segbuf->sb_sum.nsumblk - 1); 466 sci->sc_finfo_ptr = sci->sc_binfo_ptr; 467 sci->sc_blk_cnt = sci->sc_datablk_cnt = 0; 468} 469 --- 1509 unchanged lines hidden (view full) --- 1979 } 1980 return ret; 1981} 1982 1983static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, 1984 struct nilfs_sb_info *sbi) 1985{ 1986 struct nilfs_inode_info *ii, *n; |
1979 __u64 cno = sbi->s_nilfs->ns_cno; | |
1980 1981 spin_lock(&sbi->s_inode_lock); 1982 retry: 1983 list_for_each_entry_safe(ii, n, &sbi->s_dirty_files, i_dirty) { 1984 if (!ii->i_bh) { 1985 struct buffer_head *ibh; 1986 int err; 1987 --- 9 unchanged lines hidden (view full) --- 1997 nilfs_mdt_mark_dirty(sbi->s_ifile); 1998 spin_lock(&sbi->s_inode_lock); 1999 if (likely(!ii->i_bh)) 2000 ii->i_bh = ibh; 2001 else 2002 brelse(ibh); 2003 goto retry; 2004 } | 1987 1988 spin_lock(&sbi->s_inode_lock); 1989 retry: 1990 list_for_each_entry_safe(ii, n, &sbi->s_dirty_files, i_dirty) { 1991 if (!ii->i_bh) { 1992 struct buffer_head *ibh; 1993 int err; 1994 --- 9 unchanged lines hidden (view full) --- 2004 nilfs_mdt_mark_dirty(sbi->s_ifile); 2005 spin_lock(&sbi->s_inode_lock); 2006 if (likely(!ii->i_bh)) 2007 ii->i_bh = ibh; 2008 else 2009 brelse(ibh); 2010 goto retry; 2011 } |
2005 ii->i_cno = cno; | |
2006 2007 clear_bit(NILFS_I_QUEUED, &ii->i_state); 2008 set_bit(NILFS_I_BUSY, &ii->i_state); 2009 list_del(&ii->i_dirty); 2010 list_add_tail(&ii->i_dirty, &sci->sc_dirty_files); 2011 } 2012 spin_unlock(&sbi->s_inode_lock); 2013 | 2012 2013 clear_bit(NILFS_I_QUEUED, &ii->i_state); 2014 set_bit(NILFS_I_BUSY, &ii->i_state); 2015 list_del(&ii->i_dirty); 2016 list_add_tail(&ii->i_dirty, &sci->sc_dirty_files); 2017 } 2018 spin_unlock(&sbi->s_inode_lock); 2019 |
2014 NILFS_I(sbi->s_ifile)->i_cno = cno; 2015 | |
2016 return 0; 2017} 2018 2019static void nilfs_segctor_check_out_files(struct nilfs_sc_info *sci, 2020 struct nilfs_sb_info *sbi) 2021{ 2022 struct nilfs_transaction_info *ti = current->journal_info; 2023 struct nilfs_inode_info *ii, *n; | 2020 return 0; 2021} 2022 2023static void nilfs_segctor_check_out_files(struct nilfs_sc_info *sci, 2024 struct nilfs_sb_info *sbi) 2025{ 2026 struct nilfs_transaction_info *ti = current->journal_info; 2027 struct nilfs_inode_info *ii, *n; |
2024 __u64 cno = sbi->s_nilfs->ns_cno; | |
2025 2026 spin_lock(&sbi->s_inode_lock); 2027 list_for_each_entry_safe(ii, n, &sci->sc_dirty_files, i_dirty) { 2028 if (!test_and_clear_bit(NILFS_I_UPDATED, &ii->i_state) || | 2028 2029 spin_lock(&sbi->s_inode_lock); 2030 list_for_each_entry_safe(ii, n, &sci->sc_dirty_files, i_dirty) { 2031 if (!test_and_clear_bit(NILFS_I_UPDATED, &ii->i_state) || |
2029 test_bit(NILFS_I_DIRTY, &ii->i_state)) { 2030 /* The current checkpoint number (=nilfs->ns_cno) is 2031 changed between check-in and check-out only if the 2032 super root is written out. So, we can update i_cno 2033 for the inodes that remain in the dirty list. */ 2034 ii->i_cno = cno; | 2032 test_bit(NILFS_I_DIRTY, &ii->i_state)) |
2035 continue; | 2033 continue; |
2036 } | 2034 |
2037 clear_bit(NILFS_I_BUSY, &ii->i_state); 2038 brelse(ii->i_bh); 2039 ii->i_bh = NULL; 2040 list_del(&ii->i_dirty); 2041 list_add_tail(&ii->i_dirty, &ti->ti_garbage); 2042 } 2043 spin_unlock(&sbi->s_inode_lock); 2044} --- 4 unchanged lines hidden (view full) --- 2049static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) 2050{ 2051 struct nilfs_sb_info *sbi = sci->sc_sbi; 2052 struct the_nilfs *nilfs = sbi->s_nilfs; 2053 struct page *failed_page; 2054 int err; 2055 2056 sci->sc_stage.scnt = NILFS_ST_INIT; | 2035 clear_bit(NILFS_I_BUSY, &ii->i_state); 2036 brelse(ii->i_bh); 2037 ii->i_bh = NULL; 2038 list_del(&ii->i_dirty); 2039 list_add_tail(&ii->i_dirty, &ti->ti_garbage); 2040 } 2041 spin_unlock(&sbi->s_inode_lock); 2042} --- 4 unchanged lines hidden (view full) --- 2047static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) 2048{ 2049 struct nilfs_sb_info *sbi = sci->sc_sbi; 2050 struct the_nilfs *nilfs = sbi->s_nilfs; 2051 struct page *failed_page; 2052 int err; 2053 2054 sci->sc_stage.scnt = NILFS_ST_INIT; |
2055 sci->sc_cno = nilfs->ns_cno; |
|
2057 2058 err = nilfs_segctor_check_in_files(sci, sbi); 2059 if (unlikely(err)) 2060 goto out; 2061 2062 if (nilfs_test_metadata_dirty(sbi)) 2063 set_bit(NILFS_SC_DIRTY, &sci->sc_flags); 2064 --- 787 unchanged lines hidden --- | 2056 2057 err = nilfs_segctor_check_in_files(sci, sbi); 2058 if (unlikely(err)) 2059 goto out; 2060 2061 if (nilfs_test_metadata_dirty(sbi)) 2062 set_bit(NILFS_SC_DIRTY, &sci->sc_flags); 2063 --- 787 unchanged lines hidden --- |