This reverts commit 11a6fc3dc743e22fb50f2196ec55bee5140d3c52. UBIFS wants to assert that xattr operations are only issued on files with positive link count. The said patch made this operations return -ENOENT for unlinked files such that the asserts will no longer trigger. This was wrong since xattr operations are perfectly fine on unlinked files. Instead the assertions need to be fixed/removed.
Unified · Split
| @@ -152,12 +152,6 @@ static int create_xattr(struct ubifs_info *c, struct inode *host, · 151 unmodified lines | ||
| 152 | 152 | ui->data_len = size; |
| 153 | 153 | |
| 154 | 154 | mutex_lock(&host_ui->ui_mutex); |
| 155 | − | |
| 156 | − if (!host->i_nlink) { | |
| 157 | − err = -ENOENT; | |
| 158 | − goto out_noent; | |
| 159 | − } | |
| 160 | − | |
| 161 | 155 | host->i_ctime = current_time(host); |
| 162 | 156 | host_ui->xattr_cnt += 1; |
| 163 | 157 | host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm)); |
| @@ -190,7 +184,6 @@ out_cancel: · 26 unmodified lines | ||
| 190 | 184 | host_ui->xattr_size -= CALC_XATTR_BYTES(size); |
| 191 | 185 | host_ui->xattr_names -= fname_len(nm); |
| 192 | 186 | host_ui->flags &= ~UBIFS_CRYPT_FL; |
| 193 | −out_noent: | |
| 194 | 187 | mutex_unlock(&host_ui->ui_mutex); |
| 195 | 188 | out_free: |
| 196 | 189 | make_bad_inode(inode); |
| @@ -242,12 +235,6 @@ static int change_xattr(struct ubifs_info *c, struct inode *host, · 45 unmodified lines | ||
| 242 | 235 | mutex_unlock(&ui->ui_mutex); |
| 243 | 236 | |
| 244 | 237 | mutex_lock(&host_ui->ui_mutex); |
| 245 | − | |
| 246 | − if (!host->i_nlink) { | |
| 247 | − err = -ENOENT; | |
| 248 | − goto out_noent; | |
| 249 | − } | |
| 250 | − | |
| 251 | 238 | host->i_ctime = current_time(host); |
| 252 | 239 | host_ui->xattr_size -= CALC_XATTR_BYTES(old_size); |
| 253 | 240 | host_ui->xattr_size += CALC_XATTR_BYTES(size); |
| @@ -269,7 +256,6 @@ static int change_xattr(struct ubifs_info *c, struct inode *host, · 15 unmodified lines | ||
| 269 | 256 | out_cancel: |
| 270 | 257 | host_ui->xattr_size -= CALC_XATTR_BYTES(size); |
| 271 | 258 | host_ui->xattr_size += CALC_XATTR_BYTES(old_size); |
| 272 | −out_noent: | |
| 273 | 259 | mutex_unlock(&host_ui->ui_mutex); |
| 274 | 260 | make_bad_inode(inode); |
| 275 | 261 | out_free: |
| @@ -496,12 +482,6 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host, · 220 unmodified lines | ||
| 496 | 482 | return err; |
| 497 | 483 | |
| 498 | 484 | mutex_lock(&host_ui->ui_mutex); |
| 499 | − | |
| 500 | − if (!host->i_nlink) { | |
| 501 | − err = -ENOENT; | |
| 502 | − goto out_noent; | |
| 503 | − } | |
| 504 | − | |
| 505 | 485 | host->i_ctime = current_time(host); |
| 506 | 486 | host_ui->xattr_cnt -= 1; |
| 507 | 487 | host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm)); |
| @@ -521,7 +501,6 @@ out_cancel: · 13 unmodified lines | ||
| 521 | 501 | host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm)); |
| 522 | 502 | host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len); |
| 523 | 503 | host_ui->xattr_names += fname_len(nm); |
| 524 | −out_noent: | |
| 525 | 504 | mutex_unlock(&host_ui->ui_mutex); |
| 526 | 505 | ubifs_release_budget(c, &req); |
| 527 | 506 | make_bad_inode(inode); |
| @@ -561,9 +540,6 @@ static int ubifs_xattr_remove(struct inode *host, const char *name) · 33 unmodified lines | ||
| 561 | 540 | |
| 562 | 541 | ubifs_assert(c, inode_is_locked(host)); |
| 563 | 542 | |
| 564 | − if (!host->i_nlink) | |
| 565 | − return -ENOENT; | |
| 566 | − | |
| 567 | 543 | if (fname_len(&nm) > UBIFS_MAX_NLEN) |
| 568 | 544 | return -ENAMETOOLONG; |
| 569 | 545 | |