eCryptfs: Flush dirty pages in setattr

After 57db4e8d73ef2b5e94a3f412108dff2576670a8a changed eCryptfs to
write-back caching, eCryptfs page writeback updates the lower inode
times due to the use of vfs_write() on the lower file.

To preserve inode metadata changes, such as 'cp -p' does with
utimensat(), we need to flush all dirty pages early in
ecryptfs_setattr() so that the user-updated lower inode metadata isn't
clobbered later in writeback.

https://bugzilla.kernel.org/show_bug.cgi?id=33372

Reported-by: Rocko <rockorequin@hotmail.com>
Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>

+6
+6
fs/ecryptfs/inode.c
··· 929 } 930 } 931 mutex_unlock(&crypt_stat->cs_mutex); 932 memcpy(&lower_ia, ia, sizeof(lower_ia)); 933 if (ia->ia_valid & ATTR_FILE) 934 lower_ia.ia_file = ecryptfs_file_to_lower(ia->ia_file);
··· 929 } 930 } 931 mutex_unlock(&crypt_stat->cs_mutex); 932 + if (S_ISREG(inode->i_mode)) { 933 + rc = filemap_write_and_wait(inode->i_mapping); 934 + if (rc) 935 + goto out; 936 + fsstack_copy_attr_all(inode, lower_inode); 937 + } 938 memcpy(&lower_ia, ia, sizeof(lower_ia)); 939 if (ia->ia_valid & ATTR_FILE) 940 lower_ia.ia_file = ecryptfs_file_to_lower(ia->ia_file);