Loading fs/ext4/file.c +46 −36 Original line number Original line Diff line number Diff line Loading @@ -381,20 +381,21 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) return 0; return 0; } } static int ext4_file_open(struct inode * inode, struct file * filp) static int ext4_sample_last_mounted(struct super_block *sb, struct vfsmount *mnt) { { struct super_block *sb = inode->i_sb; struct ext4_sb_info *sbi = EXT4_SB(sb); struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); struct vfsmount *mnt = filp->f_path.mnt; struct path path; struct path path; char buf[64], *cp; char buf[64], *cp; int ret; handle_t *handle; int err; if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (likely(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED)) return -EIO; return 0; if (sb_rdonly(sb)) return 0; if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED) && !sb_rdonly(sb))) { sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED; sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED; /* /* * Sample where the filesystem has been mounted and * Sample where the filesystem has been mounted and Loading @@ -406,25 +407,34 @@ static int ext4_file_open(struct inode * inode, struct file * filp) path.mnt = mnt; path.mnt = mnt; path.dentry = mnt->mnt_root; path.dentry = mnt->mnt_root; cp = d_path(&path, buf, sizeof(buf)); cp = d_path(&path, buf, sizeof(buf)); if (!IS_ERR(cp)) { if (IS_ERR(cp)) handle_t *handle; return 0; int err; handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1); handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1); if (IS_ERR(handle)) if (IS_ERR(handle)) return PTR_ERR(handle); return PTR_ERR(handle); BUFFER_TRACE(sbi->s_sbh, "get_write_access"); BUFFER_TRACE(sbi->s_sbh, "get_write_access"); err = ext4_journal_get_write_access(handle, sbi->s_sbh); err = ext4_journal_get_write_access(handle, sbi->s_sbh); if (err) { if (err) ext4_journal_stop(handle); goto out; return err; } strlcpy(sbi->s_es->s_last_mounted, cp, strlcpy(sbi->s_es->s_last_mounted, cp, sizeof(sbi->s_es->s_last_mounted)); sizeof(sbi->s_es->s_last_mounted)); ext4_handle_dirty_super(handle, sb); ext4_handle_dirty_super(handle, sb); out: ext4_journal_stop(handle); ext4_journal_stop(handle); return err; } } } static int ext4_file_open(struct inode * inode, struct file * filp) { int ret; if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) return -EIO; ret = ext4_sample_last_mounted(inode->i_sb, filp->f_path.mnt); if (ret) return ret; ret = fscrypt_file_open(inode, filp); ret = fscrypt_file_open(inode, filp); if (ret) if (ret) Loading Loading
fs/ext4/file.c +46 −36 Original line number Original line Diff line number Diff line Loading @@ -381,20 +381,21 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) return 0; return 0; } } static int ext4_file_open(struct inode * inode, struct file * filp) static int ext4_sample_last_mounted(struct super_block *sb, struct vfsmount *mnt) { { struct super_block *sb = inode->i_sb; struct ext4_sb_info *sbi = EXT4_SB(sb); struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); struct vfsmount *mnt = filp->f_path.mnt; struct path path; struct path path; char buf[64], *cp; char buf[64], *cp; int ret; handle_t *handle; int err; if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (likely(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED)) return -EIO; return 0; if (sb_rdonly(sb)) return 0; if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED) && !sb_rdonly(sb))) { sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED; sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED; /* /* * Sample where the filesystem has been mounted and * Sample where the filesystem has been mounted and Loading @@ -406,25 +407,34 @@ static int ext4_file_open(struct inode * inode, struct file * filp) path.mnt = mnt; path.mnt = mnt; path.dentry = mnt->mnt_root; path.dentry = mnt->mnt_root; cp = d_path(&path, buf, sizeof(buf)); cp = d_path(&path, buf, sizeof(buf)); if (!IS_ERR(cp)) { if (IS_ERR(cp)) handle_t *handle; return 0; int err; handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1); handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1); if (IS_ERR(handle)) if (IS_ERR(handle)) return PTR_ERR(handle); return PTR_ERR(handle); BUFFER_TRACE(sbi->s_sbh, "get_write_access"); BUFFER_TRACE(sbi->s_sbh, "get_write_access"); err = ext4_journal_get_write_access(handle, sbi->s_sbh); err = ext4_journal_get_write_access(handle, sbi->s_sbh); if (err) { if (err) ext4_journal_stop(handle); goto out; return err; } strlcpy(sbi->s_es->s_last_mounted, cp, strlcpy(sbi->s_es->s_last_mounted, cp, sizeof(sbi->s_es->s_last_mounted)); sizeof(sbi->s_es->s_last_mounted)); ext4_handle_dirty_super(handle, sb); ext4_handle_dirty_super(handle, sb); out: ext4_journal_stop(handle); ext4_journal_stop(handle); return err; } } } static int ext4_file_open(struct inode * inode, struct file * filp) { int ret; if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) return -EIO; ret = ext4_sample_last_mounted(inode->i_sb, filp->f_path.mnt); if (ret) return ret; ret = fscrypt_file_open(inode, filp); ret = fscrypt_file_open(inode, filp); if (ret) if (ret) Loading