~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to fs/nilfs2/cpfile.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
328
328
                        tnicps += nicps;
329
329
                        nilfs_mdt_mark_buffer_dirty(cp_bh);
330
330
                        nilfs_mdt_mark_dirty(cpfile);
331
 
                        if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
332
 
                            (count = nilfs_cpfile_block_sub_valid_checkpoints(
333
 
                                    cpfile, cp_bh, kaddr, nicps)) == 0) {
334
 
                                /* make hole */
335
 
                                kunmap_atomic(kaddr, KM_USER0);
336
 
                                brelse(cp_bh);
337
 
                                ret = nilfs_cpfile_delete_checkpoint_block(
338
 
                                        cpfile, cno);
339
 
                                if (ret == 0)
340
 
                                        continue;
341
 
                                printk(KERN_ERR "%s: cannot delete block\n",
342
 
                                       __func__);
343
 
                                break;
 
331
                        if (!nilfs_cpfile_is_in_first(cpfile, cno)) {
 
332
                                count =
 
333
                                  nilfs_cpfile_block_sub_valid_checkpoints(
 
334
                                                cpfile, cp_bh, kaddr, nicps);
 
335
                                if (count == 0) {
 
336
                                        /* make hole */
 
337
                                        kunmap_atomic(kaddr, KM_USER0);
 
338
                                        brelse(cp_bh);
 
339
                                        ret =
 
340
                                          nilfs_cpfile_delete_checkpoint_block(
 
341
                                                                   cpfile, cno);
 
342
                                        if (ret == 0)
 
343
                                                continue;
 
344
                                        printk(KERN_ERR
 
345
                                               "%s: cannot delete block\n",
 
346
                                               __func__);
 
347
                                        break;
 
348
                                }
344
349
                        }
345
350
                }
346
351
 
858
863
 */
859
864
int nilfs_cpfile_change_cpmode(struct inode *cpfile, __u64 cno, int mode)
860
865
{
861
 
        struct the_nilfs *nilfs;
862
866
        int ret;
863
867
 
864
 
        nilfs = NILFS_MDT(cpfile)->mi_nilfs;
865
 
 
866
868
        switch (mode) {
867
869
        case NILFS_CHECKPOINT:
868
 
                /*
869
 
                 * Check for protecting existing snapshot mounts:
870
 
                 * ns_mount_mutex is used to make this operation atomic and
871
 
                 * exclusive with a new mount job.  Though it doesn't cover
872
 
                 * umount, it's enough for the purpose.
873
 
                 */
874
 
                if (nilfs_checkpoint_is_mounted(nilfs, cno, 1)) {
875
 
                        /* Current implementation does not have to protect
876
 
                           plain read-only mounts since they are exclusive
877
 
                           with a read/write mount and are protected from the
878
 
                           cleaner. */
 
870
                if (nilfs_checkpoint_is_mounted(cpfile->i_sb, cno))
 
871
                        /*
 
872
                         * Current implementation does not have to protect
 
873
                         * plain read-only mounts since they are exclusive
 
874
                         * with a read/write mount and are protected from the
 
875
                         * cleaner.
 
876
                         */
879
877
                        ret = -EBUSY;
880
 
                } else
 
878
                else
881
879
                        ret = nilfs_cpfile_clear_snapshot(cpfile, cno);
882
880
                return ret;
883
881
        case NILFS_SNAPSHOT:
926
924
        up_read(&NILFS_MDT(cpfile)->mi_sem);
927
925
        return ret;
928
926
}
 
927
 
 
928
/**
 
929
 * nilfs_cpfile_read - read or get cpfile inode
 
930
 * @sb: super block instance
 
931
 * @cpsize: size of a checkpoint entry
 
932
 * @raw_inode: on-disk cpfile inode
 
933
 * @inodep: buffer to store the inode
 
934
 */
 
935
int nilfs_cpfile_read(struct super_block *sb, size_t cpsize,
 
936
                      struct nilfs_inode *raw_inode, struct inode **inodep)
 
937
{
 
938
        struct inode *cpfile;
 
939
        int err;
 
940
 
 
941
        cpfile = nilfs_iget_locked(sb, NULL, NILFS_CPFILE_INO);
 
942
        if (unlikely(!cpfile))
 
943
                return -ENOMEM;
 
944
        if (!(cpfile->i_state & I_NEW))
 
945
                goto out;
 
946
 
 
947
        err = nilfs_mdt_init(cpfile, NILFS_MDT_GFP, 0);
 
948
        if (err)
 
949
                goto failed;
 
950
 
 
951
        nilfs_mdt_set_entry_size(cpfile, cpsize,
 
952
                                 sizeof(struct nilfs_cpfile_header));
 
953
 
 
954
        err = nilfs_read_inode_common(cpfile, raw_inode);
 
955
        if (err)
 
956
                goto failed;
 
957
 
 
958
        unlock_new_inode(cpfile);
 
959
 out:
 
960
        *inodep = cpfile;
 
961
        return 0;
 
962
 failed:
 
963
        iget_failed(cpfile);
 
964
        return err;
 
965
}