1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include "xfs.h"
19#include "xfs_fs.h"
20#include "xfs_format.h"
21#include "xfs_log_format.h"
22#include "xfs_trans_resv.h"
23#include "xfs_mount.h"
24#include "xfs_inode.h"
25#include "xfs_trans.h"
26#include "xfs_inode_item.h"
27#include "xfs_error.h"
28#include "xfs_trace.h"
29#include "xfs_trans_priv.h"
30#include "xfs_buf_item.h"
31#include "xfs_log.h"
32
33
34kmem_zone_t *xfs_ili_zone;
35
36static inline struct xfs_inode_log_item *INODE_ITEM(struct xfs_log_item *lip)
37{
38 return container_of(lip, struct xfs_inode_log_item, ili_item);
39}
40
41STATIC void
42xfs_inode_item_data_fork_size(
43 struct xfs_inode_log_item *iip,
44 int *nvecs,
45 int *nbytes)
46{
47 struct xfs_inode *ip = iip->ili_inode;
48
49 switch (ip->i_d.di_format) {
50 case XFS_DINODE_FMT_EXTENTS:
51 if ((iip->ili_fields & XFS_ILOG_DEXT) &&
52 ip->i_d.di_nextents > 0 &&
53 ip->i_df.if_bytes > 0) {
54
55 *nbytes += XFS_IFORK_DSIZE(ip);
56 *nvecs += 1;
57 }
58 break;
59 case XFS_DINODE_FMT_BTREE:
60 if ((iip->ili_fields & XFS_ILOG_DBROOT) &&
61 ip->i_df.if_broot_bytes > 0) {
62 *nbytes += ip->i_df.if_broot_bytes;
63 *nvecs += 1;
64 }
65 break;
66 case XFS_DINODE_FMT_LOCAL:
67 if ((iip->ili_fields & XFS_ILOG_DDATA) &&
68 ip->i_df.if_bytes > 0) {
69 *nbytes += roundup(ip->i_df.if_bytes, 4);
70 *nvecs += 1;
71 }
72 break;
73
74 case XFS_DINODE_FMT_DEV:
75 break;
76 default:
77 ASSERT(0);
78 break;
79 }
80}
81
82STATIC void
83xfs_inode_item_attr_fork_size(
84 struct xfs_inode_log_item *iip,
85 int *nvecs,
86 int *nbytes)
87{
88 struct xfs_inode *ip = iip->ili_inode;
89
90 switch (ip->i_d.di_aformat) {
91 case XFS_DINODE_FMT_EXTENTS:
92 if ((iip->ili_fields & XFS_ILOG_AEXT) &&
93 ip->i_d.di_anextents > 0 &&
94 ip->i_afp->if_bytes > 0) {
95
96 *nbytes += XFS_IFORK_ASIZE(ip);
97 *nvecs += 1;
98 }
99 break;
100 case XFS_DINODE_FMT_BTREE:
101 if ((iip->ili_fields & XFS_ILOG_ABROOT) &&
102 ip->i_afp->if_broot_bytes > 0) {
103 *nbytes += ip->i_afp->if_broot_bytes;
104 *nvecs += 1;
105 }
106 break;
107 case XFS_DINODE_FMT_LOCAL:
108 if ((iip->ili_fields & XFS_ILOG_ADATA) &&
109 ip->i_afp->if_bytes > 0) {
110 *nbytes += roundup(ip->i_afp->if_bytes, 4);
111 *nvecs += 1;
112 }
113 break;
114 default:
115 ASSERT(0);
116 break;
117 }
118}
119
120
121
122
123
124
125
126
127STATIC void
128xfs_inode_item_size(
129 struct xfs_log_item *lip,
130 int *nvecs,
131 int *nbytes)
132{
133 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
134 struct xfs_inode *ip = iip->ili_inode;
135
136 *nvecs += 2;
137 *nbytes += sizeof(struct xfs_inode_log_format) +
138 xfs_log_dinode_size(ip->i_d.di_version);
139
140 xfs_inode_item_data_fork_size(iip, nvecs, nbytes);
141 if (XFS_IFORK_Q(ip))
142 xfs_inode_item_attr_fork_size(iip, nvecs, nbytes);
143}
144
145STATIC void
146xfs_inode_item_format_data_fork(
147 struct xfs_inode_log_item *iip,
148 struct xfs_inode_log_format *ilf,
149 struct xfs_log_vec *lv,
150 struct xfs_log_iovec **vecp)
151{
152 struct xfs_inode *ip = iip->ili_inode;
153 size_t data_bytes;
154
155 switch (ip->i_d.di_format) {
156 case XFS_DINODE_FMT_EXTENTS:
157 iip->ili_fields &=
158 ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT | XFS_ILOG_DEV);
159
160 if ((iip->ili_fields & XFS_ILOG_DEXT) &&
161 ip->i_d.di_nextents > 0 &&
162 ip->i_df.if_bytes > 0) {
163 struct xfs_bmbt_rec *p;
164
165 ASSERT(xfs_iext_count(&ip->i_df) > 0);
166
167 p = xlog_prepare_iovec(lv, vecp, XLOG_REG_TYPE_IEXT);
168 data_bytes = xfs_iextents_copy(ip, p, XFS_DATA_FORK);
169 xlog_finish_iovec(lv, *vecp, data_bytes);
170
171 ASSERT(data_bytes <= ip->i_df.if_bytes);
172
173 ilf->ilf_dsize = data_bytes;
174 ilf->ilf_size++;
175 } else {
176 iip->ili_fields &= ~XFS_ILOG_DEXT;
177 }
178 break;
179 case XFS_DINODE_FMT_BTREE:
180 iip->ili_fields &=
181 ~(XFS_ILOG_DDATA | XFS_ILOG_DEXT | XFS_ILOG_DEV);
182
183 if ((iip->ili_fields & XFS_ILOG_DBROOT) &&
184 ip->i_df.if_broot_bytes > 0) {
185 ASSERT(ip->i_df.if_broot != NULL);
186 xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_IBROOT,
187 ip->i_df.if_broot,
188 ip->i_df.if_broot_bytes);
189 ilf->ilf_dsize = ip->i_df.if_broot_bytes;
190 ilf->ilf_size++;
191 } else {
192 ASSERT(!(iip->ili_fields &
193 XFS_ILOG_DBROOT));
194 iip->ili_fields &= ~XFS_ILOG_DBROOT;
195 }
196 break;
197 case XFS_DINODE_FMT_LOCAL:
198 iip->ili_fields &=
199 ~(XFS_ILOG_DEXT | XFS_ILOG_DBROOT | XFS_ILOG_DEV);
200 if ((iip->ili_fields & XFS_ILOG_DDATA) &&
201 ip->i_df.if_bytes > 0) {
202
203
204
205
206
207 data_bytes = roundup(ip->i_df.if_bytes, 4);
208 ASSERT(ip->i_df.if_u1.if_data != NULL);
209 ASSERT(ip->i_d.di_size > 0);
210 xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_ILOCAL,
211 ip->i_df.if_u1.if_data, data_bytes);
212 ilf->ilf_dsize = (unsigned)data_bytes;
213 ilf->ilf_size++;
214 } else {
215 iip->ili_fields &= ~XFS_ILOG_DDATA;
216 }
217 break;
218 case XFS_DINODE_FMT_DEV:
219 iip->ili_fields &=
220 ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT | XFS_ILOG_DEXT);
221 if (iip->ili_fields & XFS_ILOG_DEV)
222 ilf->ilf_u.ilfu_rdev = sysv_encode_dev(VFS_I(ip)->i_rdev);
223 break;
224 default:
225 ASSERT(0);
226 break;
227 }
228}
229
230STATIC void
231xfs_inode_item_format_attr_fork(
232 struct xfs_inode_log_item *iip,
233 struct xfs_inode_log_format *ilf,
234 struct xfs_log_vec *lv,
235 struct xfs_log_iovec **vecp)
236{
237 struct xfs_inode *ip = iip->ili_inode;
238 size_t data_bytes;
239
240 switch (ip->i_d.di_aformat) {
241 case XFS_DINODE_FMT_EXTENTS:
242 iip->ili_fields &=
243 ~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT);
244
245 if ((iip->ili_fields & XFS_ILOG_AEXT) &&
246 ip->i_d.di_anextents > 0 &&
247 ip->i_afp->if_bytes > 0) {
248 struct xfs_bmbt_rec *p;
249
250 ASSERT(xfs_iext_count(ip->i_afp) ==
251 ip->i_d.di_anextents);
252
253 p = xlog_prepare_iovec(lv, vecp, XLOG_REG_TYPE_IATTR_EXT);
254 data_bytes = xfs_iextents_copy(ip, p, XFS_ATTR_FORK);
255 xlog_finish_iovec(lv, *vecp, data_bytes);
256
257 ilf->ilf_asize = data_bytes;
258 ilf->ilf_size++;
259 } else {
260 iip->ili_fields &= ~XFS_ILOG_AEXT;
261 }
262 break;
263 case XFS_DINODE_FMT_BTREE:
264 iip->ili_fields &=
265 ~(XFS_ILOG_ADATA | XFS_ILOG_AEXT);
266
267 if ((iip->ili_fields & XFS_ILOG_ABROOT) &&
268 ip->i_afp->if_broot_bytes > 0) {
269 ASSERT(ip->i_afp->if_broot != NULL);
270
271 xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_IATTR_BROOT,
272 ip->i_afp->if_broot,
273 ip->i_afp->if_broot_bytes);
274 ilf->ilf_asize = ip->i_afp->if_broot_bytes;
275 ilf->ilf_size++;
276 } else {
277 iip->ili_fields &= ~XFS_ILOG_ABROOT;
278 }
279 break;
280 case XFS_DINODE_FMT_LOCAL:
281 iip->ili_fields &=
282 ~(XFS_ILOG_AEXT | XFS_ILOG_ABROOT);
283
284 if ((iip->ili_fields & XFS_ILOG_ADATA) &&
285 ip->i_afp->if_bytes > 0) {
286
287
288
289
290
291 data_bytes = roundup(ip->i_afp->if_bytes, 4);
292 ASSERT(ip->i_afp->if_u1.if_data != NULL);
293 xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_IATTR_LOCAL,
294 ip->i_afp->if_u1.if_data,
295 data_bytes);
296 ilf->ilf_asize = (unsigned)data_bytes;
297 ilf->ilf_size++;
298 } else {
299 iip->ili_fields &= ~XFS_ILOG_ADATA;
300 }
301 break;
302 default:
303 ASSERT(0);
304 break;
305 }
306}
307
308static void
309xfs_inode_to_log_dinode(
310 struct xfs_inode *ip,
311 struct xfs_log_dinode *to,
312 xfs_lsn_t lsn)
313{
314 struct xfs_icdinode *from = &ip->i_d;
315 struct inode *inode = VFS_I(ip);
316
317 to->di_magic = XFS_DINODE_MAGIC;
318
319 to->di_version = from->di_version;
320 to->di_format = from->di_format;
321 to->di_uid = from->di_uid;
322 to->di_gid = from->di_gid;
323 to->di_projid_lo = from->di_projid_lo;
324 to->di_projid_hi = from->di_projid_hi;
325
326 memset(to->di_pad, 0, sizeof(to->di_pad));
327 memset(to->di_pad3, 0, sizeof(to->di_pad3));
328 to->di_atime.t_sec = inode->i_atime.tv_sec;
329 to->di_atime.t_nsec = inode->i_atime.tv_nsec;
330 to->di_mtime.t_sec = inode->i_mtime.tv_sec;
331 to->di_mtime.t_nsec = inode->i_mtime.tv_nsec;
332 to->di_ctime.t_sec = inode->i_ctime.tv_sec;
333 to->di_ctime.t_nsec = inode->i_ctime.tv_nsec;
334 to->di_nlink = inode->i_nlink;
335 to->di_gen = inode->i_generation;
336 to->di_mode = inode->i_mode;
337
338 to->di_size = from->di_size;
339 to->di_nblocks = from->di_nblocks;
340 to->di_extsize = from->di_extsize;
341 to->di_nextents = from->di_nextents;
342 to->di_anextents = from->di_anextents;
343 to->di_forkoff = from->di_forkoff;
344 to->di_aformat = from->di_aformat;
345 to->di_dmevmask = from->di_dmevmask;
346 to->di_dmstate = from->di_dmstate;
347 to->di_flags = from->di_flags;
348
349
350 to->di_next_unlinked = NULLAGINO;
351
352 if (from->di_version == 3) {
353 to->di_changecount = inode->i_version;
354 to->di_crtime.t_sec = from->di_crtime.t_sec;
355 to->di_crtime.t_nsec = from->di_crtime.t_nsec;
356 to->di_flags2 = from->di_flags2;
357
358 to->di_ino = ip->i_ino;
359 to->di_lsn = lsn;
360 memset(to->di_pad2, 0, sizeof(to->di_pad2));
361 uuid_copy(&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid);
362 to->di_flushiter = 0;
363 } else {
364 to->di_flushiter = from->di_flushiter;
365 }
366}
367
368
369
370
371
372
373static void
374xfs_inode_item_format_core(
375 struct xfs_inode *ip,
376 struct xfs_log_vec *lv,
377 struct xfs_log_iovec **vecp)
378{
379 struct xfs_log_dinode *dic;
380
381 dic = xlog_prepare_iovec(lv, vecp, XLOG_REG_TYPE_ICORE);
382 xfs_inode_to_log_dinode(ip, dic, ip->i_itemp->ili_item.li_lsn);
383 xlog_finish_iovec(lv, *vecp, xfs_log_dinode_size(ip->i_d.di_version));
384}
385
386
387
388
389
390
391
392
393
394
395
396
397
398STATIC void
399xfs_inode_item_format(
400 struct xfs_log_item *lip,
401 struct xfs_log_vec *lv)
402{
403 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
404 struct xfs_inode *ip = iip->ili_inode;
405 struct xfs_log_iovec *vecp = NULL;
406 struct xfs_inode_log_format *ilf;
407
408 ASSERT(ip->i_d.di_version > 1);
409
410 ilf = xlog_prepare_iovec(lv, &vecp, XLOG_REG_TYPE_IFORMAT);
411 ilf->ilf_type = XFS_LI_INODE;
412 ilf->ilf_ino = ip->i_ino;
413 ilf->ilf_blkno = ip->i_imap.im_blkno;
414 ilf->ilf_len = ip->i_imap.im_len;
415 ilf->ilf_boffset = ip->i_imap.im_boffset;
416 ilf->ilf_fields = XFS_ILOG_CORE;
417 ilf->ilf_size = 2;
418
419
420
421
422
423 ilf->ilf_dsize = 0;
424 ilf->ilf_asize = 0;
425 ilf->ilf_pad = 0;
426 memset(&ilf->ilf_u, 0, sizeof(ilf->ilf_u));
427
428 xlog_finish_iovec(lv, vecp, sizeof(*ilf));
429
430 xfs_inode_item_format_core(ip, lv, &vecp);
431 xfs_inode_item_format_data_fork(iip, ilf, lv, &vecp);
432 if (XFS_IFORK_Q(ip)) {
433 xfs_inode_item_format_attr_fork(iip, ilf, lv, &vecp);
434 } else {
435 iip->ili_fields &=
436 ~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT);
437 }
438
439
440 ilf->ilf_fields |= (iip->ili_fields & ~XFS_ILOG_TIMESTAMP);
441}
442
443
444
445
446
447STATIC void
448xfs_inode_item_pin(
449 struct xfs_log_item *lip)
450{
451 struct xfs_inode *ip = INODE_ITEM(lip)->ili_inode;
452
453 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
454
455 trace_xfs_inode_pin(ip, _RET_IP_);
456 atomic_inc(&ip->i_pincount);
457}
458
459
460
461
462
463
464
465
466STATIC void
467xfs_inode_item_unpin(
468 struct xfs_log_item *lip,
469 int remove)
470{
471 struct xfs_inode *ip = INODE_ITEM(lip)->ili_inode;
472
473 trace_xfs_inode_unpin(ip, _RET_IP_);
474 ASSERT(atomic_read(&ip->i_pincount) > 0);
475 if (atomic_dec_and_test(&ip->i_pincount))
476 wake_up_bit(&ip->i_flags, __XFS_IPINNED_BIT);
477}
478
479
480
481
482
483
484
485
486
487STATIC void
488xfs_inode_item_error(
489 struct xfs_log_item *lip,
490 struct xfs_buf *bp)
491{
492 ASSERT(xfs_isiflocked(INODE_ITEM(lip)->ili_inode));
493 xfs_set_li_failed(lip, bp);
494}
495
496STATIC uint
497xfs_inode_item_push(
498 struct xfs_log_item *lip,
499 struct list_head *buffer_list)
500 __releases(&lip->li_ailp->xa_lock)
501 __acquires(&lip->li_ailp->xa_lock)
502{
503 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
504 struct xfs_inode *ip = iip->ili_inode;
505 struct xfs_buf *bp = lip->li_buf;
506 uint rval = XFS_ITEM_SUCCESS;
507 int error;
508
509 if (xfs_ipincount(ip) > 0)
510 return XFS_ITEM_PINNED;
511
512
513
514
515
516 if (test_bit(XFS_LI_FAILED, &lip->li_flags)) {
517 if (!xfs_buf_trylock(bp))
518 return XFS_ITEM_LOCKED;
519
520 if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
521 rval = XFS_ITEM_FLUSHING;
522
523 xfs_buf_unlock(bp);
524 return rval;
525 }
526
527 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED))
528 return XFS_ITEM_LOCKED;
529
530
531
532
533
534 if (xfs_ipincount(ip) > 0) {
535 rval = XFS_ITEM_PINNED;
536 goto out_unlock;
537 }
538
539
540
541
542 if (ip->i_flags & XFS_ISTALE) {
543 rval = XFS_ITEM_PINNED;
544 goto out_unlock;
545 }
546
547
548
549
550
551
552 if (!xfs_iflock_nowait(ip)) {
553 rval = XFS_ITEM_FLUSHING;
554 goto out_unlock;
555 }
556
557 ASSERT(iip->ili_fields != 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
558 ASSERT(iip->ili_logged == 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
559
560 spin_unlock(&lip->li_ailp->xa_lock);
561
562 error = xfs_iflush(ip, &bp);
563 if (!error) {
564 if (!xfs_buf_delwri_queue(bp, buffer_list))
565 rval = XFS_ITEM_FLUSHING;
566 xfs_buf_relse(bp);
567 }
568
569 spin_lock(&lip->li_ailp->xa_lock);
570out_unlock:
571 xfs_iunlock(ip, XFS_ILOCK_SHARED);
572 return rval;
573}
574
575
576
577
578STATIC void
579xfs_inode_item_unlock(
580 struct xfs_log_item *lip)
581{
582 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
583 struct xfs_inode *ip = iip->ili_inode;
584 unsigned short lock_flags;
585
586 ASSERT(ip->i_itemp != NULL);
587 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
588
589 lock_flags = iip->ili_lock_flags;
590 iip->ili_lock_flags = 0;
591 if (lock_flags)
592 xfs_iunlock(ip, lock_flags);
593}
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617STATIC xfs_lsn_t
618xfs_inode_item_committed(
619 struct xfs_log_item *lip,
620 xfs_lsn_t lsn)
621{
622 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
623 struct xfs_inode *ip = iip->ili_inode;
624
625 if (xfs_iflags_test(ip, XFS_ISTALE)) {
626 xfs_inode_item_unpin(lip, 0);
627 return -1;
628 }
629 return lsn;
630}
631
632STATIC void
633xfs_inode_item_committing(
634 struct xfs_log_item *lip,
635 xfs_lsn_t lsn)
636{
637 INODE_ITEM(lip)->ili_last_lsn = lsn;
638}
639
640
641
642
643static const struct xfs_item_ops xfs_inode_item_ops = {
644 .iop_size = xfs_inode_item_size,
645 .iop_format = xfs_inode_item_format,
646 .iop_pin = xfs_inode_item_pin,
647 .iop_unpin = xfs_inode_item_unpin,
648 .iop_unlock = xfs_inode_item_unlock,
649 .iop_committed = xfs_inode_item_committed,
650 .iop_push = xfs_inode_item_push,
651 .iop_committing = xfs_inode_item_committing,
652 .iop_error = xfs_inode_item_error
653};
654
655
656
657
658
659void
660xfs_inode_item_init(
661 struct xfs_inode *ip,
662 struct xfs_mount *mp)
663{
664 struct xfs_inode_log_item *iip;
665
666 ASSERT(ip->i_itemp == NULL);
667 iip = ip->i_itemp = kmem_zone_zalloc(xfs_ili_zone, KM_SLEEP);
668
669 iip->ili_inode = ip;
670 xfs_log_item_init(mp, &iip->ili_item, XFS_LI_INODE,
671 &xfs_inode_item_ops);
672}
673
674
675
676
677void
678xfs_inode_item_destroy(
679 xfs_inode_t *ip)
680{
681 kmem_free(ip->i_itemp->ili_item.li_lv_shadow);
682 kmem_zone_free(xfs_ili_zone, ip->i_itemp);
683}
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698void
699xfs_iflush_done(
700 struct xfs_buf *bp,
701 struct xfs_log_item *lip)
702{
703 struct xfs_inode_log_item *iip;
704 struct xfs_log_item *blip;
705 struct xfs_log_item *next;
706 struct xfs_log_item *prev;
707 struct xfs_ail *ailp = lip->li_ailp;
708 int need_ail = 0;
709
710
711
712
713
714 blip = bp->b_fspriv;
715 prev = NULL;
716 while (blip != NULL) {
717 if (blip->li_cb != xfs_iflush_done) {
718 prev = blip;
719 blip = blip->li_bio_list;
720 continue;
721 }
722
723
724 next = blip->li_bio_list;
725 if (!prev) {
726 bp->b_fspriv = next;
727 } else {
728 prev->li_bio_list = next;
729 }
730
731
732 blip->li_bio_list = lip->li_bio_list;
733 lip->li_bio_list = blip;
734
735
736
737
738
739 iip = INODE_ITEM(blip);
740 if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) ||
741 test_bit(XFS_LI_FAILED, &blip->li_flags))
742 need_ail++;
743
744 blip = next;
745 }
746
747
748 iip = INODE_ITEM(lip);
749 if ((iip->ili_logged && lip->li_lsn == iip->ili_flush_lsn) ||
750 test_bit(XFS_LI_FAILED, &lip->li_flags))
751 need_ail++;
752
753
754
755
756
757
758
759
760
761
762 if (need_ail) {
763 bool mlip_changed = false;
764
765
766 spin_lock(&ailp->xa_lock);
767 for (blip = lip; blip; blip = blip->li_bio_list) {
768 if (INODE_ITEM(blip)->ili_logged &&
769 blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn)
770 mlip_changed |= xfs_ail_delete_one(ailp, blip);
771 else {
772 xfs_clear_li_failed(blip);
773 }
774 }
775
776 if (mlip_changed) {
777 if (!XFS_FORCED_SHUTDOWN(ailp->xa_mount))
778 xlog_assign_tail_lsn_locked(ailp->xa_mount);
779 if (list_empty(&ailp->xa_ail))
780 wake_up_all(&ailp->xa_empty);
781 }
782 spin_unlock(&ailp->xa_lock);
783
784 if (mlip_changed)
785 xfs_log_space_wake(ailp->xa_mount);
786 }
787
788
789
790
791
792
793 for (blip = lip; blip; blip = next) {
794 next = blip->li_bio_list;
795 blip->li_bio_list = NULL;
796
797 iip = INODE_ITEM(blip);
798 iip->ili_logged = 0;
799 iip->ili_last_fields = 0;
800 xfs_ifunlock(iip->ili_inode);
801 }
802}
803
804
805
806
807
808
809
810void
811xfs_iflush_abort(
812 xfs_inode_t *ip,
813 bool stale)
814{
815 xfs_inode_log_item_t *iip = ip->i_itemp;
816
817 if (iip) {
818 if (test_bit(XFS_LI_IN_AIL, &iip->ili_item.li_flags)) {
819 xfs_trans_ail_remove(&iip->ili_item,
820 stale ? SHUTDOWN_LOG_IO_ERROR :
821 SHUTDOWN_CORRUPT_INCORE);
822 }
823 iip->ili_logged = 0;
824
825
826
827
828 iip->ili_last_fields = 0;
829
830
831
832
833 iip->ili_fields = 0;
834 iip->ili_fsync_fields = 0;
835 }
836
837
838
839 xfs_ifunlock(ip);
840}
841
842void
843xfs_istale_done(
844 struct xfs_buf *bp,
845 struct xfs_log_item *lip)
846{
847 xfs_iflush_abort(INODE_ITEM(lip)->ili_inode, true);
848}
849
850
851
852
853
854int
855xfs_inode_item_format_convert(
856 struct xfs_log_iovec *buf,
857 struct xfs_inode_log_format *in_f)
858{
859 struct xfs_inode_log_format_32 *in_f32 = buf->i_addr;
860
861 if (buf->i_len != sizeof(*in_f32))
862 return -EFSCORRUPTED;
863
864 in_f->ilf_type = in_f32->ilf_type;
865 in_f->ilf_size = in_f32->ilf_size;
866 in_f->ilf_fields = in_f32->ilf_fields;
867 in_f->ilf_asize = in_f32->ilf_asize;
868 in_f->ilf_dsize = in_f32->ilf_dsize;
869 in_f->ilf_ino = in_f32->ilf_ino;
870 memcpy(&in_f->ilf_u, &in_f32->ilf_u, sizeof(in_f->ilf_u));
871 in_f->ilf_blkno = in_f32->ilf_blkno;
872 in_f->ilf_len = in_f32->ilf_len;
873 in_f->ilf_boffset = in_f32->ilf_boffset;
874 return 0;
875}
876