aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/ubifs/journal.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index 666ad82ec51a..3bc3fc947099 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -447,13 +447,11 @@ static int get_dent_type(int mode)
447 * @ino: buffer in which to pack inode node 447 * @ino: buffer in which to pack inode node
448 * @inode: inode to pack 448 * @inode: inode to pack
449 * @last: indicates the last node of the group 449 * @last: indicates the last node of the group
450 * @last_reference: non-zero if this is a deletion inode
451 */ 450 */
452static void pack_inode(struct ubifs_info *c, struct ubifs_ino_node *ino, 451static void pack_inode(struct ubifs_info *c, struct ubifs_ino_node *ino,
453 const struct inode *inode, int last, 452 const struct inode *inode, int last)
454 int last_reference)
455{ 453{
456 int data_len = 0; 454 int data_len = 0, last_reference = !inode->i_nlink;
457 struct ubifs_inode *ui = ubifs_inode(inode); 455 struct ubifs_inode *ui = ubifs_inode(inode);
458 456
459 ino->ch.node_type = UBIFS_INO_NODE; 457 ino->ch.node_type = UBIFS_INO_NODE;
@@ -596,9 +594,9 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
596 ubifs_prep_grp_node(c, dent, dlen, 0); 594 ubifs_prep_grp_node(c, dent, dlen, 0);
597 595
598 ino = (void *)dent + aligned_dlen; 596 ino = (void *)dent + aligned_dlen;
599 pack_inode(c, ino, inode, 0, last_reference); 597 pack_inode(c, ino, inode, 0);
600 ino = (void *)ino + aligned_ilen; 598 ino = (void *)ino + aligned_ilen;
601 pack_inode(c, ino, dir, 1, 0); 599 pack_inode(c, ino, dir, 1);
602 600
603 if (last_reference) { 601 if (last_reference) {
604 err = ubifs_add_orphan(c, inode->i_ino); 602 err = ubifs_add_orphan(c, inode->i_ino);
@@ -781,7 +779,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
781 if (err) 779 if (err)
782 goto out_free; 780 goto out_free;
783 781
784 pack_inode(c, ino, inode, 1, last_reference); 782 pack_inode(c, ino, inode, 1);
785 err = write_head(c, BASEHD, ino, len, &lnum, &offs, sync); 783 err = write_head(c, BASEHD, ino, len, &lnum, &offs, sync);
786 if (err) 784 if (err)
787 goto out_release; 785 goto out_release;
@@ -912,16 +910,16 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
912 910
913 p = (void *)dent2 + aligned_dlen2; 911 p = (void *)dent2 + aligned_dlen2;
914 if (new_inode) { 912 if (new_inode) {
915 pack_inode(c, p, new_inode, 0, last_reference); 913 pack_inode(c, p, new_inode, 0);
916 p += ALIGN(ilen, 8); 914 p += ALIGN(ilen, 8);
917 } 915 }
918 916
919 if (!move) 917 if (!move)
920 pack_inode(c, p, old_dir, 1, 0); 918 pack_inode(c, p, old_dir, 1);
921 else { 919 else {
922 pack_inode(c, p, old_dir, 0, 0); 920 pack_inode(c, p, old_dir, 0);
923 p += ALIGN(plen, 8); 921 p += ALIGN(plen, 8);
924 pack_inode(c, p, new_dir, 1, 0); 922 pack_inode(c, p, new_dir, 1);
925 } 923 }
926 924
927 if (last_reference) { 925 if (last_reference) {
@@ -1126,7 +1124,7 @@ int ubifs_jnl_truncate(struct ubifs_info *c, const struct inode *inode,
1126 if (err) 1124 if (err)
1127 goto out_free; 1125 goto out_free;
1128 1126
1129 pack_inode(c, ino, inode, 0, 0); 1127 pack_inode(c, ino, inode, 0);
1130 ubifs_prep_grp_node(c, trun, UBIFS_TRUN_NODE_SZ, dlen ? 0 : 1); 1128 ubifs_prep_grp_node(c, trun, UBIFS_TRUN_NODE_SZ, dlen ? 0 : 1);
1131 if (dlen) 1129 if (dlen)
1132 ubifs_prep_grp_node(c, dn, dlen, 1); 1130 ubifs_prep_grp_node(c, dn, dlen, 1);
@@ -1246,9 +1244,9 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host,
1246 ubifs_prep_grp_node(c, xent, xlen, 0); 1244 ubifs_prep_grp_node(c, xent, xlen, 0);
1247 1245
1248 ino = (void *)xent + aligned_xlen; 1246 ino = (void *)xent + aligned_xlen;
1249 pack_inode(c, ino, inode, 0, 1); 1247 pack_inode(c, ino, inode, 0);
1250 ino = (void *)ino + UBIFS_INO_NODE_SZ; 1248 ino = (void *)ino + UBIFS_INO_NODE_SZ;
1251 pack_inode(c, ino, host, 1, 0); 1249 pack_inode(c, ino, host, 1);
1252 1250
1253 err = write_head(c, BASEHD, xent, len, &lnum, &xent_offs, sync); 1251 err = write_head(c, BASEHD, xent, len, &lnum, &xent_offs, sync);
1254 if (!sync && !err) 1252 if (!sync && !err)
@@ -1339,8 +1337,8 @@ int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode,
1339 if (err) 1337 if (err)
1340 goto out_free; 1338 goto out_free;
1341 1339
1342 pack_inode(c, ino, host, 0, 0); 1340 pack_inode(c, ino, host, 0);
1343 pack_inode(c, (void *)ino + aligned_len1, inode, 1, 0); 1341 pack_inode(c, (void *)ino + aligned_len1, inode, 1);
1344 1342
1345 err = write_head(c, BASEHD, ino, aligned_len, &lnum, &offs, 0); 1343 err = write_head(c, BASEHD, ino, aligned_len, &lnum, &offs, 0);
1346 if (!sync && !err) { 1344 if (!sync && !err) {