Skip to content

Commit 9df9c8b

Browse files
author
Jens Axboe
committed
ecryptfs: add bdi backing to mount session
This ensures that dirty data gets flushed properly. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent 5163d90 commit 9df9c8b

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎fs/ecryptfs/ecryptfs_kernel.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/scatterlist.h>
3636
#include <linux/hash.h>
3737
#include <linux/nsproxy.h>
38+
#include <linux/backing-dev.h>
3839

3940
/* Version verification for shared data structures w/ userspace */
4041
#define ECRYPTFS_VERSION_MAJOR 0x00
@@ -393,6 +394,7 @@ struct ecryptfs_mount_crypt_stat {
393394
struct ecryptfs_sb_info {
394395
struct super_block *wsi_sb;
395396
struct ecryptfs_mount_crypt_stat mount_crypt_stat;
397+
struct backing_dev_info bdi;
396398
};
397399

398400
/* file private data. */

‎fs/ecryptfs/main.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,17 +497,25 @@ struct kmem_cache *ecryptfs_sb_info_cache;
497497
static int
498498
ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent)
499499
{
500+
struct ecryptfs_sb_info *esi;
500501
int rc = 0;
501502

502503
/* Released in ecryptfs_put_super() */
503504
ecryptfs_set_superblock_private(sb,
504505
kmem_cache_zalloc(ecryptfs_sb_info_cache,
505506
GFP_KERNEL));
506-
if (!ecryptfs_superblock_to_private(sb)) {
507+
esi = ecryptfs_superblock_to_private(sb);
508+
if (!esi) {
507509
ecryptfs_printk(KERN_WARNING, "Out of memory\n");
508510
rc = -ENOMEM;
509511
goto out;
510512
}
513+
514+
rc = bdi_setup_and_register(&esi->bdi, "ecryptfs", BDI_CAP_MAP_COPY);
515+
if (rc)
516+
goto out;
517+
518+
sb->s_bdi = &esi->bdi;
511519
sb->s_op = &ecryptfs_sops;
512520
/* Released through deactivate_super(sb) from get_sb_nodev */
513521
sb->s_root = d_alloc(NULL, &(const struct qstr) {

‎fs/ecryptfs/super.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static void ecryptfs_put_super(struct super_block *sb)
122122
lock_kernel();
123123

124124
ecryptfs_destroy_mount_crypt_stat(&sb_info->mount_crypt_stat);
125+
bdi_destroy(&sb_info->bdi);
125126
kmem_cache_free(ecryptfs_sb_info_cache, sb_info);
126127
ecryptfs_set_superblock_private(sb, NULL);
127128

0 commit comments

Comments
 (0)