@@ -1175,10 +1175,20 @@ zfs_create(znode_t *dzp, const char *name, vattr_t *vap, int excl, int mode,
1175
1175
return (error );
1176
1176
}
1177
1177
zfs_mknode (dzp , vap , tx , cr , 0 , & zp , & acl_ids );
1178
+
1179
+ error = zfs_link_create (dzp , name , zp , tx , ZNEW );
1180
+ if (error != 0 ) {
1181
+ VOP_UNLOCK1 (ZTOV (zp ));
1182
+ zrele (zp );
1183
+ zfs_acl_ids_free (& acl_ids );
1184
+ dmu_tx_commit (tx );
1185
+ getnewvnode_drop_reserve ();
1186
+ goto out ;
1187
+ }
1188
+
1178
1189
if (fuid_dirtied )
1179
1190
zfs_fuid_sync (zfsvfs , tx );
1180
1191
1181
- (void ) zfs_link_create (dzp , name , zp , tx , ZNEW );
1182
1192
txtype = zfs_log_create_txtype (Z_FILE , vsecp , vap );
1183
1193
zfs_log_create (zilog , tx , txtype , dzp , zp , name ,
1184
1194
vsecp , acl_ids .z_fuidp , vap );
@@ -1526,20 +1536,26 @@ zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp,
1526
1536
*/
1527
1537
zfs_mknode (dzp , vap , tx , cr , 0 , & zp , & acl_ids );
1528
1538
1529
- if (fuid_dirtied )
1530
- zfs_fuid_sync (zfsvfs , tx );
1531
-
1532
1539
/*
1533
1540
* Now put new name in parent dir.
1534
1541
*/
1535
- (void ) zfs_link_create (dzp , dirname , zp , tx , ZNEW );
1542
+ error = zfs_link_create (dzp , dirname , zp , tx , ZNEW );
1543
+ if (error != 0 ) {
1544
+ VOP_UNLOCK1 (ZTOV (zp ));
1545
+ zrele (zp );
1546
+ goto out ;
1547
+ }
1548
+
1549
+ if (fuid_dirtied )
1550
+ zfs_fuid_sync (zfsvfs , tx );
1536
1551
1537
1552
* zpp = zp ;
1538
1553
1539
1554
txtype = zfs_log_create_txtype (Z_DIR , NULL , vap );
1540
1555
zfs_log_create (zilog , tx , txtype , dzp , zp , dirname , NULL ,
1541
1556
acl_ids .z_fuidp , vap );
1542
1557
1558
+ out :
1543
1559
zfs_acl_ids_free (& acl_ids );
1544
1560
1545
1561
dmu_tx_commit (tx );
@@ -1550,7 +1566,7 @@ zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp,
1550
1566
zil_commit (zilog , 0 );
1551
1567
1552
1568
zfs_exit (zfsvfs , FTAG );
1553
- return (0 );
1569
+ return (error );
1554
1570
}
1555
1571
1556
1572
#if __FreeBSD_version < 1300124
@@ -3586,19 +3602,26 @@ zfs_symlink(znode_t *dzp, const char *name, vattr_t *vap,
3586
3602
/*
3587
3603
* Insert the new object into the directory.
3588
3604
*/
3589
- (void ) zfs_link_create (dzp , name , zp , tx , ZNEW );
3590
-
3591
- zfs_log_symlink (zilog , tx , txtype , dzp , zp , name , link );
3592
- * zpp = zp ;
3605
+ error = zfs_link_create (dzp , name , zp , tx , ZNEW );
3606
+ if (error != 0 ) {
3607
+ VOP_UNLOCK1 (ZTOV (zp ));
3608
+ zrele (zp );
3609
+ } else {
3610
+ zfs_log_symlink (zilog , tx , txtype , dzp , zp , name , link );
3611
+ }
3593
3612
3594
3613
zfs_acl_ids_free (& acl_ids );
3595
3614
3596
3615
dmu_tx_commit (tx );
3597
3616
3598
3617
getnewvnode_drop_reserve ();
3599
3618
3600
- if (zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
3601
- zil_commit (zilog , 0 );
3619
+ if (error == 0 ) {
3620
+ * zpp = zp ;
3621
+
3622
+ if (zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
3623
+ zil_commit (zilog , 0 );
3624
+ }
3602
3625
3603
3626
zfs_exit (zfsvfs , FTAG );
3604
3627
return (error );
0 commit comments