@@ -1495,128 +1495,6 @@ static int ext4_nfs_commit_metadata(struct inode *inode)
14951495 return ext4_write_inode (inode , & wbc );
14961496}
14971497
1498- #ifdef CONFIG_FS_ENCRYPTION
1499- static int ext4_get_context (struct inode * inode , void * ctx , size_t len )
1500- {
1501- return ext4_xattr_get (inode , EXT4_XATTR_INDEX_ENCRYPTION ,
1502- EXT4_XATTR_NAME_ENCRYPTION_CONTEXT , ctx , len );
1503- }
1504-
1505- static int ext4_set_context (struct inode * inode , const void * ctx , size_t len ,
1506- void * fs_data )
1507- {
1508- handle_t * handle = fs_data ;
1509- int res , res2 , credits , retries = 0 ;
1510-
1511- /*
1512- * Encrypting the root directory is not allowed because e2fsck expects
1513- * lost+found to exist and be unencrypted, and encrypting the root
1514- * directory would imply encrypting the lost+found directory as well as
1515- * the filename "lost+found" itself.
1516- */
1517- if (inode -> i_ino == EXT4_ROOT_INO )
1518- return - EPERM ;
1519-
1520- if (WARN_ON_ONCE (IS_DAX (inode ) && i_size_read (inode )))
1521- return - EINVAL ;
1522-
1523- if (ext4_test_inode_flag (inode , EXT4_INODE_DAX ))
1524- return - EOPNOTSUPP ;
1525-
1526- res = ext4_convert_inline_data (inode );
1527- if (res )
1528- return res ;
1529-
1530- /*
1531- * If a journal handle was specified, then the encryption context is
1532- * being set on a new inode via inheritance and is part of a larger
1533- * transaction to create the inode. Otherwise the encryption context is
1534- * being set on an existing inode in its own transaction. Only in the
1535- * latter case should the "retry on ENOSPC" logic be used.
1536- */
1537-
1538- if (handle ) {
1539- res = ext4_xattr_set_handle (handle , inode ,
1540- EXT4_XATTR_INDEX_ENCRYPTION ,
1541- EXT4_XATTR_NAME_ENCRYPTION_CONTEXT ,
1542- ctx , len , 0 );
1543- if (!res ) {
1544- ext4_set_inode_flag (inode , EXT4_INODE_ENCRYPT );
1545- ext4_clear_inode_state (inode ,
1546- EXT4_STATE_MAY_INLINE_DATA );
1547- /*
1548- * Update inode->i_flags - S_ENCRYPTED will be enabled,
1549- * S_DAX may be disabled
1550- */
1551- ext4_set_inode_flags (inode , false);
1552- }
1553- return res ;
1554- }
1555-
1556- res = dquot_initialize (inode );
1557- if (res )
1558- return res ;
1559- retry :
1560- res = ext4_xattr_set_credits (inode , len , false /* is_create */ ,
1561- & credits );
1562- if (res )
1563- return res ;
1564-
1565- handle = ext4_journal_start (inode , EXT4_HT_MISC , credits );
1566- if (IS_ERR (handle ))
1567- return PTR_ERR (handle );
1568-
1569- res = ext4_xattr_set_handle (handle , inode , EXT4_XATTR_INDEX_ENCRYPTION ,
1570- EXT4_XATTR_NAME_ENCRYPTION_CONTEXT ,
1571- ctx , len , 0 );
1572- if (!res ) {
1573- ext4_set_inode_flag (inode , EXT4_INODE_ENCRYPT );
1574- /*
1575- * Update inode->i_flags - S_ENCRYPTED will be enabled,
1576- * S_DAX may be disabled
1577- */
1578- ext4_set_inode_flags (inode , false);
1579- res = ext4_mark_inode_dirty (handle , inode );
1580- if (res )
1581- EXT4_ERROR_INODE (inode , "Failed to mark inode dirty" );
1582- }
1583- res2 = ext4_journal_stop (handle );
1584-
1585- if (res == - ENOSPC && ext4_should_retry_alloc (inode -> i_sb , & retries ))
1586- goto retry ;
1587- if (!res )
1588- res = res2 ;
1589- return res ;
1590- }
1591-
1592- static const union fscrypt_policy * ext4_get_dummy_policy (struct super_block * sb )
1593- {
1594- return EXT4_SB (sb )-> s_dummy_enc_policy .policy ;
1595- }
1596-
1597- static bool ext4_has_stable_inodes (struct super_block * sb )
1598- {
1599- return ext4_has_feature_stable_inodes (sb );
1600- }
1601-
1602- static void ext4_get_ino_and_lblk_bits (struct super_block * sb ,
1603- int * ino_bits_ret , int * lblk_bits_ret )
1604- {
1605- * ino_bits_ret = 8 * sizeof (EXT4_SB (sb )-> s_es -> s_inodes_count );
1606- * lblk_bits_ret = 8 * sizeof (ext4_lblk_t );
1607- }
1608-
1609- static const struct fscrypt_operations ext4_cryptops = {
1610- .key_prefix = "ext4:" ,
1611- .get_context = ext4_get_context ,
1612- .set_context = ext4_set_context ,
1613- .get_dummy_policy = ext4_get_dummy_policy ,
1614- .empty_dir = ext4_empty_dir ,
1615- .has_stable_inodes = ext4_has_stable_inodes ,
1616- .get_ino_and_lblk_bits = ext4_get_ino_and_lblk_bits ,
1617- };
1618- #endif
1619-
16201498#ifdef CONFIG_QUOTA
16211499static const char * const quotatypes [] = INITQFNAMES ;
16221500#define QTYPE2NAME (t ) (quotatypes[t])
0 commit comments