.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * This file is part of UBIFS. |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2006-2008 Nokia Corporation. |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify it |
---|
7 | | - * under the terms of the GNU General Public License version 2 as published by |
---|
8 | | - * the Free Software Foundation. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
---|
11 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
12 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
13 | | - * more details. |
---|
14 | | - * |
---|
15 | | - * You should have received a copy of the GNU General Public License along with |
---|
16 | | - * this program; if not, write to the Free Software Foundation, Inc., 51 |
---|
17 | | - * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
18 | 6 | * |
---|
19 | 7 | * Authors: Artem Bityutskiy (Битюцкий Артём) |
---|
20 | 8 | * Adrian Hunter |
---|
.. | .. |
---|
236 | 224 | bud->lnum = lnum; |
---|
237 | 225 | bud->start = offs; |
---|
238 | 226 | bud->jhead = jhead; |
---|
| 227 | + bud->log_hash = NULL; |
---|
239 | 228 | |
---|
240 | 229 | ref->ch.node_type = UBIFS_REF_NODE; |
---|
241 | 230 | ref->lnum = cpu_to_le32(bud->lnum); |
---|
.. | .. |
---|
272 | 261 | c->lhead_lnum, c->lhead_offs); |
---|
273 | 262 | err = ubifs_write_node(c, ref, UBIFS_REF_NODE_SZ, c->lhead_lnum, |
---|
274 | 263 | c->lhead_offs); |
---|
| 264 | + if (err) |
---|
| 265 | + goto out_unlock; |
---|
| 266 | + |
---|
| 267 | + err = ubifs_shash_update(c, c->log_hash, ref, UBIFS_REF_NODE_SZ); |
---|
| 268 | + if (err) |
---|
| 269 | + goto out_unlock; |
---|
| 270 | + |
---|
| 271 | + err = ubifs_shash_copy_state(c, c->log_hash, c->jheads[jhead].log_hash); |
---|
275 | 272 | if (err) |
---|
276 | 273 | goto out_unlock; |
---|
277 | 274 | |
---|
.. | .. |
---|
377 | 374 | cs->cmt_no = cpu_to_le64(c->cmt_no); |
---|
378 | 375 | ubifs_prepare_node(c, cs, UBIFS_CS_NODE_SZ, 0); |
---|
379 | 376 | |
---|
| 377 | + err = ubifs_shash_init(c, c->log_hash); |
---|
| 378 | + if (err) |
---|
| 379 | + goto out; |
---|
| 380 | + |
---|
| 381 | + err = ubifs_shash_update(c, c->log_hash, cs, UBIFS_CS_NODE_SZ); |
---|
| 382 | + if (err < 0) |
---|
| 383 | + goto out; |
---|
| 384 | + |
---|
380 | 385 | /* |
---|
381 | 386 | * Note, we do not lock 'c->log_mutex' because this is the commit start |
---|
382 | 387 | * phase and we are exclusively using the log. And we do not lock |
---|
.. | .. |
---|
402 | 407 | |
---|
403 | 408 | ubifs_prepare_node(c, ref, UBIFS_REF_NODE_SZ, 0); |
---|
404 | 409 | len += UBIFS_REF_NODE_SZ; |
---|
| 410 | + |
---|
| 411 | + err = ubifs_shash_update(c, c->log_hash, ref, |
---|
| 412 | + UBIFS_REF_NODE_SZ); |
---|
| 413 | + if (err) |
---|
| 414 | + goto out; |
---|
| 415 | + ubifs_shash_copy_state(c, c->log_hash, c->jheads[i].log_hash); |
---|
405 | 416 | } |
---|
406 | 417 | |
---|
407 | 418 | ubifs_pad(c, buf + len, ALIGN(len, c->min_io_size) - len); |
---|
.. | .. |
---|
427 | 438 | *ltail_lnum = c->lhead_lnum; |
---|
428 | 439 | |
---|
429 | 440 | c->lhead_offs += len; |
---|
430 | | - if (c->lhead_offs == c->leb_size) { |
---|
431 | | - c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum); |
---|
432 | | - c->lhead_offs = 0; |
---|
433 | | - } |
---|
| 441 | + ubifs_assert(c, c->lhead_offs < c->leb_size); |
---|
434 | 442 | |
---|
435 | 443 | remove_buds(c); |
---|
436 | 444 | |
---|
.. | .. |
---|
516 | 524 | if (err) |
---|
517 | 525 | return err; |
---|
518 | 526 | list_del(&bud->list); |
---|
| 527 | + kfree(bud->log_hash); |
---|
519 | 528 | kfree(bud); |
---|
520 | 529 | } |
---|
521 | 530 | mutex_lock(&c->log_mutex); |
---|