linux/fs/ocfs2/reservations.c
<<
v3.tio/spa>28 tio/form28 tioa v3.ti href="../linux+v3/op7/fs/ocfs2/reserva2e=>s.c"> v3.tioimg src="../.sta2ec/gfx/right.png" alt=">>"> vo/spa>28 vospa> class="lxr_search"> v3.="+search" method="post" =>submit="return do_search(this);"> v3.tioinput typ.12hidden" nam.12navtarget" e=v3.12"> v3.tioinput typ.12text" nam.12search" id12search"> v3.tiobuttlu2typ.12submit">Search28 vospa> class="lxr_prefs"28 tioa href="+prefs?return=fs/ocfs2/reserva2e=>s.c" v3.ti onclick="return ajax_prefs();"> v3.tiPrefs8 tio/a> vo/spa>283.ti io/div283.ti ioform ac2e=>="ajax+*" method="post" =>submit="return false;"> voinput typ.12hidden" nam.12ajax_lookup" id12ajax_lookup" e=v3.12"> 3.ti io/form28 3.ti iodiv class="headingbottlm">8 odiv id12file_contents"2
i i1o/a>ospa> class="comment">/* -*- mode: c; c-basic-offset: 8; -*-o/spa>28i i2o/a>ospa> class="comment"> * vim: noexpa>dtab sw=8 ts=8 sts=0:o/spa>28i i3o/a>ospa> class="comment"> *o/spa>28i i4o/a>ospa> class="comment"> * reserva2e=>s.co/spa>28i i5o/a>ospa> class="comment"> *o/spa>28i i6o/a>ospa> class="comment"> * Alloca2e=> reserva2e=>s implementa2e=>o/spa>28i i7o/a>ospa> class="comment"> *o/spa>28i i8o/a>ospa> class="comment"> * Some code borrowed from fs/ext3/balloc.c a>d is:o/spa>28i i9o/a>ospa> class="comment"> *o/spa>28i ="17a>ospa> class="comment"> * Copyright (C) 1992, 1993, 1994, 1995o/spa>28i 11o/a>ospa> class="comment"> * Remy Card (card@masi.ibp.fr)o/spa>28i 12o/a>ospa> class="comment"> * Laboratoire MASI - Institut Blaise Pascalo/spa>28i 13o/a>ospa> class="comment"> * Universite Pierre et Marie Curie (Paris VI)o/spa>28i 14o/a>ospa> class="comment"> *o/spa>28i 15o/a>ospa> class="comment"> * The rest is copyright (C) 2010 Novell.  All rights reserved.o/spa>28i 16o/a>ospa> class="comment"> *o/spa>28i 17o/a>ospa> class="comment"> * This program is free software; you ca> redistribute it a>d/oro/spa>28i 18o/a>ospa> class="comment"> * modify it under the terms of the GNU General Publico/spa>28i 19o/a>ospa> class="comment"> * License versi=> 2 as published by the Free Software Founda2e=>.o/spa>28i 2"17a>ospa> class="comment"> *o/spa>28i 21o/a>ospa> class="comment"> * This program is distributed in the hope that it will be useful,o/spa>28i 22o/a>ospa> class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty ofo/spa>28i 23o/a>ospa> class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUo/spa>28i 24o/a>ospa> class="comment"> * General Public License for more details.o/spa>28i 25o/a>ospa> class="comment"> */o/spa>28i 26o/a>8i 27o/a>#include <linux/fs.ho/a>>8i 28o/a>#include <linux/typ.s.ho/a>>8i 29o/a>#include <linux/highmem.ho/a>>8i 30o/a>#include <linux/bitops.ho/a>>8i 31o/a>#include <linux/list.ho/a>>8i 32o/a>8i 33o/a>#include <cluster/masklog.ho/a>>8i 34o/a>8i 35o/a>#include "ocfs2.ho/a>"8i 36o/a>#include "ocfs2_trace.ho/a>"8i 37o/a>8i 38o/a>#ifdefioa href="+code=CONFIG_OCFS2_DEBUG_FS" class="sref">CONFIG_OCFS2_DEBUG_FSo/a>8i 39o/a>#defineioa href="+code=OCFS2_CHECK_RESERVATIONS" class="sref">OCFS2_CHECK_RESERVATIONSo/a>8i 40o/a>#endif8i 41o/a>8i 42o/a>oa href="+code=DEFINE_SPINLOCK" class="sref">DEFINE_SPINLOCKo/a>(oa href="+code=resv_lock" class="sref">resv_locko/a>);8i 43o/a>8i 44o/a>#defineioa href="+code=OCFS2_MIN_RESV_WINDOW_BITS" class="sref">OCFS2_MIN_RESV_WINDOW_BITSo/a>3.ti i88i 45o/a>#defineioa href="+code=OCFS2_MAX_RESV_WINDOW_BITS" class="sref">OCFS2_MAX_RESV_WINDOW_BITSo/a>3.ti i10248i 46o/a>8i 47o/a>intioa href="+code=ocfs2_dir_resv_allowed" class="sref">ocfs2_dir_resv_allowedo/a>(structioa href="+code=ocfs2_super" class="sref">ocfs2_supero/a>3*oa href="+code=osb" class="sref">osbo/a>)8i 48o/a>{8i 49o/a>3.ti i  return (oa href="+code=osb" class="sref">osbo/a>->oa href="+code=osb_resv_level" class="sref">osb_resv_levelo/a>3&&ioa href="+code=osb" class="sref">osbo/a>->oa href="+code=osb_dir_resv_level" class="sref">osb_dir_resv_levelo/a>);8i 50o/a>}8i 51o/a>8i 52o/a>sta2ec unsigned intioa href="+code=ocfs2_resv_window_bits" class="sref">ocfs2_resv_window_bitso/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i 53o/a>3.ti i                                     structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>)8i 54o/a>{8i 55o/a>3.ti i  structioa href="+code=ocfs2_super" class="sref">ocfs2_supero/a>3*oa href="+code=osb" class="sref">osbo/a> =ioa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_osb" class="sref">m_osbo/a>;8i 56o/a>3.ti i  unsigned intioa href="+code=bits" class="sref">bitso/a>;8i 57o/a>8i 58o/a>3.ti i  if (!(oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_flags" class="sref">r_flagso/a>3&ioa href="+code=OCFS2_RESV_FLAG_DIR" class="sref">OCFS2_RESV_FLAG_DIRo/a>)) {8i 59o/a>3.ti i          ospa> class="comment">/* 8, 16, 32, 64, 128, 256, 512, 1024 */o/spa>28i 60o/a>3.ti i          oa href="+code=bits" class="sref">bitso/a> =i4 <<ioa href="+code=osb" class="sref">osbo/a>->oa href="+code=osb_resv_level" class="sref">osb_resv_levelo/a>;8i 61o/a>3.ti i  } else {8i 62o/a>3.ti i          oa href="+code=bits" class="sref">bitso/a> =i4 <<ioa href="+code=osb" class="sref">osbo/a>->oa href="+code=osb_dir_resv_level" class="sref">osb_dir_resv_levelo/a>;8i 63o/a>3.ti i  }8i 64o/a>3.ti i  return oa href="+code=bits" class="sref">bitso/a>;8i 65o/a>}8i 66o/a>8i 67o/a>sta2ec oa href="+code=inline" class="sref">inlineo/a>3unsigned intioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>)8i 68o/a>{8i 69o/a>3.ti i  if (oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>)8i 70o/a>3.ti i          return oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>3+ oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a> - 1;8i 71o/a>3.ti i  return oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>;8i 72o/a>}8i 73o/a>8i 74o/a>sta2ec oa href="+code=inline" class="sref">inlineo/a>3intioa href="+code=ocfs2_resv_empty" class="sref">ocfs2_resv_emptyo/a>(structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>)8i 75o/a>{8i 76o/a>3.ti i  return !!(oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a> == 0);8i 77o/a>}8i 78o/a>8i 79o/a>sta2ec oa href="+code=inline" class="sref">inlineo/a>3intioa href="+code=ocfs2_resmap_disabled" class="sref">ocfs2_resmap_disabledo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>)8i 80o/a>{8i 81o/a>3.ti i  if (oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_osb" class="sref">m_osbo/a>->oa href="+code=osb_resv_level" class="sref">osb_resv_levelo/a>3== 0)8i 82o/a>3.ti i          return 1;8i 83o/a>3.ti i  return 0;8i 84o/a>}8i 85o/a>8i 86o/a>sta2ec voidioa href="+code=ocfs2_dump_resv" class="sref">ocfs2_dump_resvo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>)8i 87o/a>{8i 88o/a>3.ti i  structioa href="+code=ocfs2_super" class="sref">ocfs2_supero/a>3*oa href="+code=osb" class="sref">osbo/a> =ioa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_osb" class="sref">m_osbo/a>;8i 89o/a>3.ti i  structioa href="+code=rb_node" class="sref">rb_nodeo/a>3*oa href="+code=node" class="sref">nodeo/a>;8i 90o/a>3.ti i  structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>;8i 91o/a>3.ti i  intioa href="+code=i" class="sref">io/a> =i0;8i 92o/a>8i 93o/a>3.ti i  oa href="+code=mlog" class="sref">mlogo/a>(oa href="+code=ML_NOTICE" class="sref">ML_NOTICEo/a>, ospa> class="string">"Dumping resmap for device %s. Bitmap le>gth: %u\n"2,8i 94o/a>3.ti i       oa href="+code=osb" class="sref">osbo/a>->oa href="+code=dev_str" class="sref">dev_stro/a>, oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_bitmap_le>" class="sref">m_bitmap_le>o/a>);8i 95o/a>8i 96o/a>3.ti i  oa href="+code=node" class="sref">nodeo/a> =ioa href="+code=rb_first" class="sref">rb_firsto/a>(&oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_reserva2e=>s" class="sref">m_reserva2e=>so/a>);8i 97o/a>3.ti i  while (oa href="+code=node" class="sref">nodeo/a>) {8i 98o/a>3.ti i       i  oa href="+code=resv" class="sref">resvo/a> =ioa href="+code=rb_entry" class="sref">rb_entryo/a>(oa href="+code=node" class="sref">nodeo/a>, structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>, oa href="+code=r_node" class="sref">r_nodeo/a>);8i 99o/a>8i100o/a>3.ti i       i  oa href="+code=mlog" class="sref">mlogo/a>(oa href="+code=ML_NOTICE" class="sref">ML_NOTICEo/a>, ospa> class="string">"start: %u\tend: %u\tle>: %u\tlast_start: %u"28i101o/a>3.ti i       i    i  ospa> class="string">"\tlast_le>: %u\n"2, oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>,8i102o/a>3.ti i               oa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>), oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>, oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_start" class="sref">r_last_starto/a>,8i103o/a>3.ti i               oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_le>" class="sref">r_last_le>o/a>);8i104o/a>8i105o/a>3.ti i       i  oa href="+code=node" class="sref">nodeo/a> =ioa href="+code=rb_next" class="sref">rb_nexto/a>(oa href="+code=node" class="sref">nodeo/a>);8i106o/a>3.ti i       i  oa href="+code=i" class="sref">io/a>++;8i107o/a>3.ti i  }8i108o/a>8i109o/a>3.ti i  oa href="+code=mlog" class="sref">mlogo/a>(oa href="+code=ML_NOTICE" class="sref">ML_NOTICEo/a>, ospa> class="string">"%d reserva2e=>s found. LRU follows\n"2, oa href="+code=i" class="sref">io/a>);8i1="17a>8i111o/a>3.ti i  oa href="+code=i" class="sref">io/a> =i0;8i112o/a>3.ti i  oa href="+code=list_for_each_entry" class="sref">list_for_each_entryo/a>(oa href="+code=resv" class="sref">resvo/a>, &oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_lru" class="sref">m_lruo/a>, oa href="+code=r_lru" class="sref">r_lruo/a>) {8i113o/a>3.ti i          oa href="+code=mlog" class="sref">mlogo/a>(oa href="+code=ML_NOTICE" class="sref">ML_NOTICEo/a>, ospa> class="string">"LRU(%d) start: %u\tend: %u\tle>: %u\t"28i114o/a>3.ti i       i    i  ospa> class="string">"last_start: %u\tlast_le>: %u\n"2, oa href="+code=i" class="sref">io/a>, oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>,8i115o/a>3.ti i       i       oa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>), oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>, oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_start" class="sref">r_last_starto/a>,8i116o/a>3.ti i       i       oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_le>" class="sref">r_last_le>o/a>);8i117o/a>8i118o/a>3.ti i       i  oa href="+code=i" class="sref">io/a>++;8i119o/a>3.ti i  }8i120o/a>}8i121o/a>8i122o/a>#ifdefioa href="+code=OCFS2_CHECK_RESERVATIONS" class="sref">OCFS2_CHECK_RESERVATIONSo/a>8i123o/a>sta2ec intioa href="+code=ocfs2_validate_resmap_bits" class="sref">ocfs2_validate_resmap_bitso/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i124o/a>3.ti i       i    i                   intioa href="+code=i" class="sref">io/a>,8i125o/a>3.ti i       i                        structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>)8i126o/a>{8i127o/a>3.ti i  char3*oa href="+code=disk_bitmap" class="sref">disk_bitmapo/a> =ioa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_disk_bitmap" class="sref">m_disk_bitmapo/a>;8i128o/a>3.ti i  unsigned intioa href="+code=start" class="sref">starto/a>3=ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>;8i129o/a>3.ti i  unsigned intioa href="+code=end" class="sref">endo/a>3=ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>);8i13"17a>8i131o/a>3.ti i  while (oa href="+code=start" class="sref">starto/a>3<=ioa href="+code=end" class="sref">endo/a>) {8i132o/a>3.ti i          if (oa href="+code=ocfs2_test_bit" class="sref">ocfs2_test_bito/a>(oa href="+code=start" class="sref">starto/a>, oa href="+code=disk_bitmap" class="sref">disk_bitmapo/a>)) {8i133o/a>3.ti i                  oa href="+code=mlog" class="sref">mlogo/a>(oa href="+code=ML_ERROR" class="sref">ML_ERRORo/a>,8i134o/a>3.ti i       i    i          ospa> class="string">"reserva2e=> %d covers a> alloca2ed area "28i135o/a>3.ti i       i               ospa> class="string">"starting at bit %u!\n"2, oa href="+code=i" class="sref">io/a>, oa href="+code=start" class="sref">starto/a>);8i136o/a>3.ti i       i          return 1;8i137o/a>3.ti i       i  }8i138o/a>8i139o/a>3.ti i          oa href="+code=start" class="sref">starto/a>++;8i140o/a>3.ti i  }8i141o/a>3.ti i  return 0;8i142o/a>}8i143o/a>8i144o/a>sta2ec voidioa href="+code=ocfs2_check_resmap" class="sref">ocfs2_check_resmapo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>)8i145o/a>{8i146o/a>3.ti i  unsigned intioa href="+code=off" class="sref">offo/a> =i0;8i147o/a>3.ti i  intioa href="+code=i" class="sref">io/a> =i0;8i148o/a>3.ti i  structioa href="+code=rb_node" class="sref">rb_nodeo/a>3*oa href="+code=node" class="sref">nodeo/a>;8i149o/a>3.ti i  structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>;8i15"17a>8i151o/a>3.ti i  oa href="+code=node" class="sref">nodeo/a> =ioa href="+code=rb_first" class="sref">rb_firsto/a>(&oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_reserva2e=>s" class="sref">m_reserva2e=>so/a>);8i152o/a>3.ti i  while (oa href="+code=node" class="sref">nodeo/a>) {8i153o/a>3.ti i          oa href="+code=resv" class="sref">resvo/a> =ioa href="+code=rb_entry" class="sref">rb_entryo/a>(oa href="+code=node" class="sref">nodeo/a>, structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>, oa href="+code=r_node" class="sref">r_nodeo/a>);8i154o/a>8i155o/a>3.ti i       i  if (oa href="+code=i" class="sref">io/a> > 03&&ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>3<=ioa href="+code=off" class="sref">offo/a>) {8i156o/a>3.ti i       i          oa href="+code=mlog" class="sref">mlogo/a>(oa href="+code=ML_ERROR" class="sref">ML_ERRORo/a>, ospa> class="string">"reserva2e=> %d has bad start off!\n"2,8i157o/a>3.ti i       i    i          oa href="+code=i" class="sref">io/a>);8i158o/a>3.ti i       i          goto oa href="+code=bad" class="sref">bado/a>;8i159o/a>3.ti i          }8i16"17a>8i161o/a>3.ti i       i  if (oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>3== 0) {8i162o/a>3.ti i                  oa href="+code=mlog" class="sref">mlogo/a>(oa href="+code=ML_ERROR" class="sref">ML_ERRORo/a>, ospa> class="string">"reserva2e=> %d has no le>gth!\n"2,8i163o/a>3.ti i                       oa href="+code=i" class="sref">io/a>);8i164o/a>3.ti i       i    i     goto oa href="+code=bad" class="sref">bado/a>;8i165o/a>3.ti i       i  }8i166o/a>8i167o/a>3.ti i       i  if (oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>3>ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>)) {8i168o/a>3.ti i       i          oa href="+code=mlog" class="sref">mlogo/a>(oa href="+code=ML_ERROR" class="sref">ML_ERRORo/a>, ospa> class="string">"reserva2e=> %d has invalid range!\n"2,8i169o/a>3.ti i                       oa href="+code=i" class="sref">io/a>);8i170o/a>3.ti i            i     goto oa href="+code=bad" class="sref">bado/a>;8i171o/a>3.ti i       i  }8i172o/a>8i173o/a>3.ti i          if (oa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>)3>=ioa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_bitmap_le>" class="sref">m_bitmap_le>o/a>) {8i174o/a>3.ti i       i    i     oa href="+code=mlog" class="sref">mlogo/a>(oa href="+code=ML_ERROR" class="sref">ML_ERRORo/a>, ospa> class="string">"reserva2e=> %d extends past bitmap!\n"2,8i175o/a>3.ti i       i               oa href="+code=i" class="sref">io/a>);8i176o/a>3.ti i       i          goto oa href="+code=bad" class="sref">bado/a>;8i177o/a>3.ti i       i  }8i178o/a>8i179o/a>3.ti i          if (oa href="+code=ocfs2_validate_resmap_bits" class="sref">ocfs2_validate_resmap_bitso/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=i" class="sref">io/a>, oa href="+code=resv" class="sref">resvo/a>))8i180o/a>3.ti i            i     goto oa href="+code=bad" class="sref">bado/a>;8i181o/a>8i182o/a>3.ti i          oa href="+code=off" class="sref">offo/a> =ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>);8i183o/a>3.ti i          oa href="+code=node" class="sref">nodeo/a> =ioa href="+code=rb_next" class="sref">rb_nexto/a>(oa href="+code=node" class="sref">nodeo/a>);8i184o/a>8i185o/a>3.ti i       i  oa href="+code=i" class="sref">io/a>++;8i186o/a>3.ti i  }8i187o/a>3.ti i  return;8i188o/a>8i189o/a>oa href="+code=bad" class="sref">bado/a>:8i190o/a>3.ti i  oa href="+code=ocfs2_dump_resv" class="sref">ocfs2_dump_resvo/a>(oa href="+code=resmap" class="sref">resmapo/a>);8i191o/a>3.ti i  oa href="+code=BUG" class="sref">BUGo/a>();8i192o/a>}8i193o/a>#else8i194o/a>sta2ec oa href="+code=inline" class="sref">inlineo/a>3voidioa href="+code=ocfs2_check_resmap" class="sref">ocfs2_check_resmapo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>)8i195o/a>{8i196o/a>8i197o/a>}8i198o/a>#endif8i199o/a>8i200o/a>voidioa href="+code=ocfs2_resv_init_once" class="sref">ocfs2_resv_init_onceo/a>(structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>)8i201o/a>{8i202o/a>3.ti i  oa href="+code=memset" class="sref">memseto/a>(oa href="+code=resv" class="sref">resvo/a>, 0, sizeof(*oa href="+code=resv" class="sref">resvo/a>));8i203o/a>3.ti i  oa href="+code=INIT_LIST_HEAD" class="sref">INIT_LIST_HEADo/a>(&oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_lru" class="sref">r_lruo/a>);8i204o/a>}8i205o/a>8i206o/a>voidioa href="+code=ocfs2_resv_set_typ." class="sref">ocfs2_resv_set_typ.o/a>(structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>,8i207o/a>3.ti i       i    i      unsigned intioa href="+code=flags" class="sref">flagso/a>)8i208o/a>{8i209o/a>3.ti i  oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(oa href="+code=flags" class="sref">flagso/a>3&i~oa href="+code=OCFS2_RESV_TYPES" class="sref">OCFS2_RESV_TYPESo/a>);8i2="17a>8i211o/a>3.ti i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_flags" class="sref">r_flagso/a>3|=ioa href="+code=flags" class="sref">flagso/a>;8i212o/a>}8i213o/a>8i214o/a>intioa href="+code=ocfs2_resmap_init" class="sref">ocfs2_resmap_inito/a>(structioa href="+code=ocfs2_super" class="sref">ocfs2_supero/a>3*oa href="+code=osb" class="sref">osbo/a>,8i215o/a>3.ti i       i        structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>)8i216o/a>{8i217o/a>3.ti i  oa href="+code=memset" class="sref">memseto/a>(oa href="+code=resmap" class="sref">resmapo/a>, 0, sizeof(*oa href="+code=resmap" class="sref">resmapo/a>));8i218o/a>8i219o/a>3.ti i  oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_osb" class="sref">m_osbo/a> =ioa href="+code=osb" class="sref">osbo/a>;8i220o/a>3.ti i  oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_reserva2e=>s" class="sref">m_reserva2e=>so/a> =ioa href="+code=RB_ROOT" class="sref">RB_ROOTo/a>;8i221o/a>3.ti i  ospa> class="comment">/* m_bitmap_le> is initialized to zero by the above memset. */o/spa>28i222o/a>3.ti i  oa href="+code=INIT_LIST_HEAD" class="sref">INIT_LIST_HEADo/a>(&oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_lru" class="sref">m_lruo/a>);8i223o/a>8i224o/a>3.ti i  return 0;8i225o/a>}8i226o/a>8i227o/a>sta2ec voidioa href="+code=ocfs2_resv_mark_lru" class="sref">ocfs2_resv_mark_lruo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i228o/a>3.ti i       i                  structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>)8i229o/a>{8i230o/a>3.ti i  oa href="+code=assert_spin_locked" class="sref">assert_spin_lockedo/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i231o/a>8i232o/a>3.ti i  if (!oa href="+code=list_empty" class="sref">list_emptyo/a>(&oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_lru" class="sref">r_lruo/a>))8i233o/a>3.ti i          oa href="+code=list_del_init" class="sref">list_del_inito/a>(&oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_lru" class="sref">r_lruo/a>);8i234o/a>8i235o/a>3.ti i  oa href="+code=list_add_tail" class="sref">list_add_tailo/a>(&oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_lru" class="sref">r_lruo/a>, &oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_lru" class="sref">m_lruo/a>);8i236o/a>}8i237o/a>8i238o/a>sta2ec voidioa href="+code=__ocfs2_resv_trunc" class="sref">__ocfs2_resv_trunco/a>(structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>)8i239o/a>{8i240o/a>3.ti i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>3= 0;8i241o/a>3.ti i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>3= 0;8i242o/a>}8i243o/a>8i244o/a>sta2ec voidioa href="+code=ocfs2_resv_remove" class="sref">ocfs2_resv_removeo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i245o/a>3.ti i       i                structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>)8i246o/a>{8i247o/a>3.ti i  if (oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_flags" class="sref">r_flagso/a>3&ioa href="+code=OCFS2_RESV_FLAG_INUSE" class="sref">OCFS2_RESV_FLAG_INUSEo/a>) {8i248o/a>3.ti i       i  oa href="+code=list_del_init" class="sref">list_del_inito/a>(&oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_lru" class="sref">r_lruo/a>);8i249o/a>3.ti i          oa href="+code=rb_erase" class="sref">rb_eraseo/a>(&oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_node" class="sref">r_nodeo/a>, &oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_reserva2e=>s" class="sref">m_reserva2e=>so/a>);8i250o/a>3.ti i       i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_flags" class="sref">r_flagso/a>3&=i~oa href="+code=OCFS2_RESV_FLAG_INUSE" class="sref">OCFS2_RESV_FLAG_INUSEo/a>;8i251o/a>3.ti i  }8i252o/a>}8i253o/a>8i254o/a>sta2ec voidioa href="+code=__ocfs2_resv_discard" class="sref">__ocfs2_resv_discardo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i255o/a>3.ti i       i  i                structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>)8i256o/a>{8i257o/a>3.ti i  oa href="+code=assert_spin_locked" class="sref">assert_spin_lockedo/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i258o/a>8i259o/a>3.ti i  oa href="+code=__ocfs2_resv_trunc" class="sref">__ocfs2_resv_trunco/a>(oa href="+code=resv" class="sref">resvo/a>);8i260o/a>3.ti i  ospa> class="comment">/*o/spa>28i261o/a>ospa> class="comment">         * last_le> and last_start no longer make sense ifo/spa>28i262o/a>ospa> class="comment">         * we're changing the range of our alloca2e=>s.o/spa>28i263o/a>ospa> class="comment">         */o/spa>28i264o/a>3.ti i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_le>" class="sref">r_last_le>o/a>3=ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_start" class="sref">r_last_starto/a>3= 0;8i265o/a>8i266o/a>3.ti i  oa href="+code=ocfs2_resv_remove" class="sref">ocfs2_resv_removeo/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>);8i267o/a>}8i268o/a>8i269o/a>ospa> class="comment">/* does nothing if 'resv' is null */o/spa>28i270o/a>voidioa href="+code=ocfs2_resv_discard" class="sref">ocfs2_resv_discardo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i271o/a>3.ti i       i          structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>)8i272o/a>{8i273o/a>3.ti i  if (oa href="+code=resv" class="sref">resvo/a>) {8i274o/a>3.ti i       i  oa href="+code=spin_lock" class="sref">spin_locko/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i275o/a>3.ti i       i  oa href="+code=__ocfs2_resv_discard" class="sref">__ocfs2_resv_discardo/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>);8i276o/a>3.ti i       i  oa href="+code=spin_unlock" class="sref">spin_unlocko/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i277o/a>3.ti i  }8i278o/a>}8i279o/a>8i280o/a>sta2ec voidioa href="+code=ocfs2_resmap_clear_all_resv" class="sref">ocfs2_resmap_clear_all_resvo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>)8i281o/a>{8i282o/a>3.ti i  structioa href="+code=rb_node" class="sref">rb_nodeo/a>3*oa href="+code=node" class="sref">nodeo/a>;8i283o/a>3.ti i  structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>;8i284o/a>8i285o/a>3.ti i  oa href="+code=assert_spin_locked" class="sref">assert_spin_lockedo/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i286o/a>8i287o/a>3.ti i  while ((oa href="+code=node" class="sref">nodeo/a> =ioa href="+code=rb_last" class="sref">rb_lasto/a>(&oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_reserva2e=>s" class="sref">m_reserva2e=>so/a>)) !=ioa href="+code=NULL" class="sref">NULLo/a>) {8i288o/a>3.ti i       i  oa href="+code=resv" class="sref">resvo/a> =ioa href="+code=rb_entry" class="sref">rb_entryo/a>(oa href="+code=node" class="sref">nodeo/a>, structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>, oa href="+code=r_node" class="sref">r_nodeo/a>);8i289o/a>8i290o/a>3.ti i       i  oa href="+code=__ocfs2_resv_discard" class="sref">__ocfs2_resv_discardo/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>);8i291o/a>3.ti i  }8i292o/a>}8i293o/a>8i294o/a>voidioa href="+code=ocfs2_resmap_restart" class="sref">ocfs2_resmap_restarto/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i295o/a>3.ti i       i  i         unsigned intioa href="+code=cle>" class="sref">cle>o/a>, char3*oa href="+code=disk_bitmap" class="sref">disk_bitmapo/a>)8i296o/a>{8i297o/a>3.ti i  if (oa href="+code=ocfs2_resmap_disabled" class="sref">ocfs2_resmap_disabledo/a>(oa href="+code=resmap" class="sref">resmapo/a>))8i298o/a>3.ti i       i  return;8i299o/a>8i300o/a>3.ti i  oa href="+code=spin_lock" class="sref">spin_locko/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i301o/a>8i302o/a>3.ti i  oa href="+code=ocfs2_resmap_clear_all_resv" class="sref">ocfs2_resmap_clear_all_resvo/a>(oa href="+code=resmap" class="sref">resmapo/a>);8i303o/a>3.ti i  oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_bitmap_le>" class="sref">m_bitmap_le>o/a> =ioa href="+code=cle>" class="sref">cle>o/a>;8i304o/a>3.ti i  oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_disk_bitmap" class="sref">m_disk_bitmapo/a> =ioa href="+code=disk_bitmap" class="sref">disk_bitmapo/a>;8i305o/a>8i306o/a>3.ti i  oa href="+code=spin_unlock" class="sref">spin_unlocko/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i307o/a>}8i308o/a>8i309o/a>voidioa href="+code=ocfs2_resmap_uninit" class="sref">ocfs2_resmap_uninito/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>)8i3="17a>{8i311o/a>3.ti i  ospa> class="comment">/* Does nothing for now. Keep this around for API symmetry */o/spa>28i312o/a>}8i313o/a>8i314o/a>sta2ec voidioa href="+code=ocfs2_resv_insert" class="sref">ocfs2_resv_inserto/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i315o/a>3.ti i       i                structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=new" class="sref">newo/a>)8i316o/a>{8i317o/a>3.ti i  structioa href="+code=rb_root" class="sref">rb_rooto/a>3*oa href="+code=root" class="sref">rooto/a>3= &oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_reserva2e=>s" class="sref">m_reserva2e=>so/a>;8i318o/a>3.ti i  structioa href="+code=rb_node" class="sref">rb_nodeo/a>3*oa href="+code=parent" class="sref">parento/a> =ioa href="+code=NULL" class="sref">NULLo/a>;8i319o/a>3.ti i  structioa href="+code=rb_node" class="sref">rb_nodeo/a>3**oa href="+code=p" class="sref">po/a>3= &oa href="+code=root" class="sref">rooto/a>->oa href="+code=rb_node" class="sref">rb_nodeo/a>;8i320o/a>3.ti i  structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=tmp" class="sref">tmpo/a>;8i321o/a>8i322o/a>3.ti i  oa href="+code=assert_spin_locked" class="sref">assert_spin_lockedo/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i323o/a>8i324o/a>3.ti i  oa href="+code=trace_ocfs2_resv_insert" class="sref">trace_ocfs2_resv_inserto/a>(oa href="+code=new" class="sref">newo/a>->oa href="+code=r_start" class="sref">r_starto/a>, oa href="+code=new" class="sref">newo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>);8i325o/a>8i326o/a>3.ti i  while (*oa href="+code=p" class="sref">po/a>) {8i327o/a>3.ti i       i  oa href="+code=parent" class="sref">parento/a> =i*oa href="+code=p" class="sref">po/a>;8i328o/a>8i329o/a>3.ti i          oa href="+code=tmp" class="sref">tmpo/a> =ioa href="+code=rb_entry" class="sref">rb_entryo/a>(oa href="+code=parent" class="sref">parento/a>, structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>, oa href="+code=r_node" class="sref">r_nodeo/a>);8i33"17a>8i331o/a>3.ti i       i  if (oa href="+code=new" class="sref">newo/a>->oa href="+code=r_start" class="sref">r_starto/a>3< oa href="+code=tmp" class="sref">tmpo/a>->oa href="+code=r_start" class="sref">r_starto/a>) {8i332o/a>3.ti i                  oa href="+code=p" class="sref">po/a>3= &(*oa href="+code=p" class="sref">po/a>)->oa href="+code=rb_left" class="sref">rb_lefto/a>;8i333o/a>8i334o/a>3.ti i       i    i     ospa> class="comment">/*o/spa>28i335o/a>ospa> class="comment">                         * This is a good place to check foro/spa>28i336o/a>ospa> class="comment">                         * overlapping reserva2e=>s.o/spa>28i337o/a>ospa> class="comment">                         */o/spa>28i338o/a>3.ti i       i          oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(oa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=new" class="sref">newo/a>)3>=ioa href="+code=tmp" class="sref">tmpo/a>->oa href="+code=r_start" class="sref">r_starto/a>);8i339o/a>3.ti i          } else if (oa href="+code=new" class="sref">newo/a>->oa href="+code=r_start" class="sref">r_starto/a>3>ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=tmp" class="sref">tmpo/a>)) {8i340o/a>3.ti i       i          oa href="+code=p" class="sref">po/a>3= &(*oa href="+code=p" class="sref">po/a>)->oa href="+code=rb_right" class="sref">rb_righto/a>;8i341o/a>3.ti i       i  } else {8i342o/a>3.ti i                  ospa> class="comment">/* This should never happen! */o/spa>28i343o/a>3.ti i                  oa href="+code=mlog" class="sref">mlogo/a>(oa href="+code=ML_ERROR" class="sref">ML_ERRORo/a>, ospa> class="string">"Duplicate reserva2e=> window!\n"2);8i344o/a>3.ti i       i    i     oa href="+code=BUG" class="sref">BUGo/a>();8i345o/a>3.ti i       i  }8i346o/a>3.ti i  }8i347o/a>8i348o/a>3.ti i  oa href="+code=rb_link_node" class="sref">rb_link_nodeo/a>(&oa href="+code=new" class="sref">newo/a>->oa href="+code=r_node" class="sref">r_nodeo/a>, oa href="+code=parent" class="sref">parento/a>, oa href="+code=p" class="sref">po/a>);8i349o/a>3.ti i  oa href="+code=rb_insert_color" class="sref">rb_insert_coloro/a>(&oa href="+code=new" class="sref">newo/a>->oa href="+code=r_node" class="sref">r_nodeo/a>, oa href="+code=root" class="sref">rooto/a>);8i350o/a>3.ti i  oa href="+code=new" class="sref">newo/a>->oa href="+code=r_flags" class="sref">r_flagso/a>3|=ioa href="+code=OCFS2_RESV_FLAG_INUSE" class="sref">OCFS2_RESV_FLAG_INUSEo/a>;8i351o/a>8i352o/a>3.ti i  oa href="+code=ocfs2_resv_mark_lru" class="sref">ocfs2_resv_mark_lruo/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=new" class="sref">newo/a>);8i353o/a>8i354o/a>3.ti i  oa href="+code=ocfs2_check_resmap" class="sref">ocfs2_check_resmapo/a>(oa href="+code=resmap" class="sref">resmapo/a>);8i355o/a>}8i356o/a>8i357o/a>ospa> class="comment">/**o/spa>28i358o/a>ospa> class="comment"> * ocfs2_find_resv_lhs() - find the window which contains goalo/spa>28i359o/a>ospa> class="comment"> * @resmap: reserva2e=> map to searcho/spa>28i360o/a>ospa> class="comment"> * @goal: which bit to search foro/spa>28i361o/a>ospa> class="comment"> *o/spa>28i362o/a>ospa> class="comment"> * If a window containing that goal is not found, we return the windowo/spa>28i363o/a>ospa> class="comment"> * which comes before goal. Returns NULL => empty rbtree or no windowo/spa>28i364o/a>ospa> class="comment"> * before goal.o/spa>28i365o/a>ospa> class="comment"> */o/spa>28i366o/a>sta2ec structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*8i367o/a>oa href="+code=ocfs2_find_resv_lhs" class="sref">ocfs2_find_resv_lhso/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>, unsigned intioa href="+code=goal" class="sref">goalo/a>)8i368o/a>{8i369o/a>3.ti i  structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a> =ioa href="+code=NULL" class="sref">NULLo/a>;8i370o/a>3.ti i  structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=prev_resv" class="sref">prev_resvo/a> =ioa href="+code=NULL" class="sref">NULLo/a>;8i371o/a>3.ti i  structioa href="+code=rb_node" class="sref">rb_nodeo/a>3*oa href="+code=node" class="sref">nodeo/a>3=ioa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_reserva2e=>s" class="sref">m_reserva2e=>so/a>.oa href="+code=rb_node" class="sref">rb_nodeo/a>;8i372o/a>8i373o/a>3.ti i  oa href="+code=assert_spin_locked" class="sref">assert_spin_lockedo/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i374o/a>8i375o/a>3.ti i  if (!oa href="+code=node" class="sref">nodeo/a>)8i376o/a>3.ti i       i  return oa href="+code=NULL" class="sref">NULLo/a>;8i377o/a>8i378o/a>3.ti i  oa href="+code=node" class="sref">nodeo/a> =ioa href="+code=rb_first" class="sref">rb_firsto/a>(&oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_reserva2e=>s" class="sref">m_reserva2e=>so/a>);8i379o/a>3.ti i  while (oa href="+code=node" class="sref">nodeo/a>) {8i380o/a>3.ti i       i  oa href="+code=resv" class="sref">resvo/a> =ioa href="+code=rb_entry" class="sref">rb_entryo/a>(oa href="+code=node" class="sref">nodeo/a>, structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>, oa href="+code=r_node" class="sref">r_nodeo/a>);8i381o/a>8i382o/a>3.ti i          if (oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>3<=ioa href="+code=goal" class="sref">goalo/a> &&ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>)3>=ioa href="+code=goal" class="sref">goalo/a>)8i383o/a>3.ti i                  break;8i384o/a>8i385o/a>3.ti i       i  ospa> class="comment">/* Check if we overshot the reserva2e=> just before goal? */o/spa>28i386o/a>3.ti i       i  if (oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>3>ioa href="+code=goal" class="sref">goalo/a>) {8i387o/a>3.ti i       i    i     oa href="+code=resv" class="sref">resvo/a> =ioa href="+code=prev_resv" class="sref">prev_resvo/a>;8i388o/a>3.ti i       i          break;8i389o/a>3.ti i          }8i39"17a>8i391o/a>3.ti i       i  oa href="+code=prev_resv" class="sref">prev_resvo/a> =ioa href="+code=resv" class="sref">resvo/a>;8i392o/a>3.ti i          oa href="+code=node" class="sref">nodeo/a> =ioa href="+code=rb_next" class="sref">rb_nexto/a>(oa href="+code=node" class="sref">nodeo/a>);8i393o/a>3.ti i  }8i394o/a>8i395o/a>3.ti i  return oa href="+code=resv" class="sref">resvo/a>;8i396o/a>}8i397o/a>8i398o/a>ospa> class="comment">/*o/spa>28i399o/a>ospa> class="comment"> * We are give> a range within the bitmap, which corresponds to a gapo/spa>28i400o/a>ospa> class="comment"> * inside the reserva2e=>s tree (search_start, search_le>). The rangeo/spa>28i401o/a>ospa> class="comment"> * ca> be anything from the whole bitmap, to a gap betwee>o/spa>28i402o/a>ospa> class="comment"> * reserva2e=>s.o/spa>28i403o/a>ospa> class="comment"> *o/spa>28i404o/a>ospa> class="comment"> * The start value of *rstart is insignifica>t.o/spa>28i405o/a>ospa> class="comment"> *o/spa>28i406o/a>ospa> class="comment"> * This func2e=> searches the bitmap range starting at search_starto/spa>28i407o/a>ospa> class="comment"> * with le>gth search_le> for a set of contiguous free bits. We tryo/spa>28i408o/a>ospa> class="comment"> * to find up to 'wa>ted' bits, but ca> sometimes return less.o/spa>28i409o/a>ospa> class="comment"> *o/spa>28i410o/a>ospa> class="comment"> * Returns the le>gth of alloca2e=>, 0 if no free bits are found.o/spa>28i411o/a>ospa> class="comment"> *o/spa>28i412o/a>ospa> class="comment"> * *cstart and *cle> will also be populated with the result.o/spa>28i413o/a>ospa> class="comment"> */o/spa>28i414o/a>sta2ec intioa href="+code=ocfs2_resmap_find_free_bits" class="sref">ocfs2_resmap_find_free_bitso/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i415o/a>3.ti i       i                         unsigned intioa href="+code=wa>ted" class="sref">wa>tedo/a>,8i416o/a>3.ti i       i                         unsigned intioa href="+code=search_start" class="sref">search_starto/a>,8i417o/a>3.ti i       i    i                    unsigned intioa href="+code=search_le>" class="sref">search_le>o/a>,8i418o/a>3.ti i       i                         unsigned inti*oa href="+code=rstart" class="sref">rstarto/a>,8i419o/a>3.ti i                                 unsigned inti*oa href="+code=rle>" class="sref">rle>o/a>)8i42"17a>{8i421o/a>3.ti i  voidi*oa href="+code=bitmap" class="sref">bitmapo/a> =ioa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_disk_bitmap" class="sref">m_disk_bitmapo/a>;8i422o/a>3.ti i  unsigned intioa href="+code=best_start" class="sref">best_starto/a>, oa href="+code=best_le>" class="sref">best_le>o/a> =i0;8i423o/a>3.ti i  intioa href="+code=offset" class="sref">offseto/a>, oa href="+code=start" class="sref">starto/a>, oa href="+code=found" class="sref">foundo/a>;8i424o/a>8i425o/a>3.ti i  oa href="+code=trace_ocfs2_resmap_find_free_bits_begi>" class="sref">trace_ocfs2_resmap_find_free_bits_begi>o/a>(oa href="+code=search_start" class="sref">search_starto/a>,ioa href="+code=search_le>" class="sref">search_le>o/a>,8i426o/a>3.ti i       i                                  oa href="+code=wa>ted" class="sref">wa>tedo/a>, oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_bitmap_le>" class="sref">m_bitmap_le>o/a>);8i427o/a>8i428o/a>3.ti i  oa href="+code=found" class="sref">foundo/a> =ioa href="+code=best_start" class="sref">best_starto/a> =ioa href="+code=best_le>" class="sref">best_le>o/a> =i0;8i429o/a>8i430o/a>3.ti i  oa href="+code=start" class="sref">starto/a> =ioa href="+code=search_start" class="sref">search_starto/a>;8i431o/a>3.ti i  while ((oa href="+code=offset" class="sref">offseto/a> =ioa href="+code=ocfs2_find_next_zero_bit" class="sref">ocfs2_find_next_zero_bito/a>(oa href="+code=bitmap" class="sref">bitmapo/a>, oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_bitmap_le>" class="sref">m_bitmap_le>o/a>,8i432o/a>3.ti i                                           oa href="+code=start" class="sref">starto/a>)) !=i-1) {8i433o/a>3.ti i          ospa> class="comment">/* Search reached end of the rege=> */o/spa>28i434o/a>3.ti i       i  if (oa href="+code=offset" class="sref">offseto/a> >=i(oa href="+code=search_start" class="sref">search_starto/a> +ioa href="+code=search_le>" class="sref">search_le>o/a>))8i435o/a>3.ti i       i          break;8i436o/a>8i437o/a>3.ti i       i  if (oa href="+code=offset" class="sref">offseto/a> ==ioa href="+code=start" class="sref">starto/a>) {8i438o/a>3.ti i       i          ospa> class="comment">/* we found a zero */o/spa>28i439o/a>3.ti i                  oa href="+code=found" class="sref">foundo/a>++;8i440o/a>3.ti i       i          ospa> class="comment">/* move start to the next bit to test */o/spa>28i441o/a>3.ti i       i          oa href="+code=start" class="sref">starto/a>++;8i442o/a>3.ti i          } else {8i443o/a>3.ti i                  ospa> class="comment">/* got a zero after some ones */o/spa>28i444o/a>3.ti i       i    i     oa href="+code=found" class="sref">foundo/a> =i1;8i445o/a>3.ti i       i          oa href="+code=start" class="sref">starto/a> =ioa href="+code=offset" class="sref">offseto/a> +i1;8i446o/a>3.ti i       i  }8i447o/a>3.ti i       i  if (oa href="+code=found" class="sref">foundo/a> >ioa href="+code=best_le>" class="sref">best_le>o/a>) {8i448o/a>3.ti i       i          oa href="+code=best_le>" class="sref">best_le>o/a> =ioa href="+code=found" class="sref">foundo/a>;8i449o/a>3.ti i                  oa href="+code=best_start" class="sref">best_starto/a> =ioa href="+code=start" class="sref">starto/a> -ioa href="+code=found" class="sref">foundo/a>;8i450o/a>3.ti i       i  }8i451o/a>8i452o/a>3.ti i          if (oa href="+code=found" class="sref">foundo/a> >=ioa href="+code=wa>ted" class="sref">wa>tedo/a>)8i453o/a>3.ti i                  break;8i454o/a>3.ti i  }8i455o/a>8i456o/a>3.ti i  if (oa href="+code=best_le>" class="sref">best_le>o/a> == 0)8i457o/a>3.ti i       i  return 0;8i458o/a>8i459o/a>3.ti i  if (oa href="+code=best_le>" class="sref">best_le>o/a> >=ioa href="+code=wa>ted" class="sref">wa>tedo/a>)8i460o/a>3.ti i       i  oa href="+code=best_le>" class="sref">best_le>o/a> =ioa href="+code=wa>ted" class="sref">wa>tedo/a>;8i461o/a>8i462o/a>3.ti i  *oa href="+code=rle>" class="sref">rle>o/a> =ioa href="+code=best_le>" class="sref">best_le>o/a>;8i463o/a>3.ti i  *oa href="+code=rstart" class="sref">rstarto/a> =ioa href="+code=best_start" class="sref">best_starto/a>;8i464o/a>8i465o/a>3.ti i  oa href="+code=trace_ocfs2_resmap_find_free_bits_end" class="sref">trace_ocfs2_resmap_find_free_bits_endo/a>(oa href="+code=best_start" class="sref">best_starto/a>, oa href="+code=best_le>" class="sref">best_le>o/a>);8i466o/a>8i467o/a>3.ti i  return *oa href="+code=rle>" class="sref">rle>o/a>;8i468o/a>}8i469o/a>8i470o/a>sta2ec voidioa href="+code=__ocfs2_resv_find_window" class="sref">__ocfs2_resv_find_windowo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i471o/a>3.ti i       i                       structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>,8i472o/a>3.ti i                               unsigned intioa href="+code=goal" class="sref">goalo/a>, unsigned intioa href="+code=wa>ted" class="sref">wa>tedo/a>)8i473o/a>{8i474o/a>3.ti i  structioa href="+code=rb_root" class="sref">rb_rooto/a>3*oa href="+code=root" class="sref">rooto/a>3= &oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_reserva2e=>s" class="sref">m_reserva2e=>so/a>;8i475o/a>3.ti i  unsigned intioa href="+code=gap_start" class="sref">gap_starto/a>, oa href="+code=gap_end" class="sref">gap_endo/a>, oa href="+code=gap_le>" class="sref">gap_le>o/a>;8i476o/a>3.ti i  structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=prev_resv" class="sref">prev_resvo/a>,3*oa href="+code=next_resv" class="sref">next_resvo/a>;8i477o/a>3.ti i  structioa href="+code=rb_node" class="sref">rb_nodeo/a>3*oa href="+code=prev" class="sref">prevo/a>,3*oa href="+code=next" class="sref">nexto/a>;8i478o/a>3.ti i  unsigned intioa href="+code=cstart" class="sref">cstarto/a>, oa href="+code=cle>" class="sref">cle>o/a>;8i479o/a>3.ti i  unsigned intioa href="+code=best_start" class="sref">best_starto/a> =i0, oa href="+code=best_le>" class="sref">best_le>o/a> =i0;8i48"17a>8i481o/a>3.ti i  ospa> class="comment">/*o/spa>28i482o/a>ospa> class="comment">         * Nasty cases to consider:o/spa>28i483o/a>ospa> class="comment">         *o/spa>28i484o/a>ospa> class="comment">         * - rbtree is emptyo/spa>28i485o/a>ospa> class="comment">         * - our window should be first in all reserva2e=>so/spa>28i486o/a>ospa> class="comment">         * - our window should be last in all reserva2e=>so/spa>28i487o/a>ospa> class="comment">         * - need to make sure we don't go past end of bitmapo/spa>28i488o/a>ospa> class="comment">         */o/spa>28i489o/a>3.ti i  oa href="+code=trace_ocfs2_resv_find_window_begi>" class="sref">trace_ocfs2_resv_find_window_begi>o/a>(oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>, oa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>),8i490o/a>3.ti i       i                             oa href="+code=goal" class="sref">goalo/a>, oa href="+code=wa>ted" class="sref">wa>tedo/a>, oa href="+code=RB_EMPTY_ROOT" class="sref">RB_EMPTY_ROOTo/a>(oa href="+code=root" class="sref">rooto/a>));8i491o/a>8i492o/a>3.ti i  oa href="+code=assert_spin_locked" class="sref">assert_spin_lockedo/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i493o/a>8i494o/a>3.ti i  if (oa href="+code=RB_EMPTY_ROOT" class="sref">RB_EMPTY_ROOTo/a>(oa href="+code=root" class="sref">rooto/a>)) {8i495o/a>3.ti i       i  ospa> class="comment">/*o/spa>28i496o/a>ospa> class="comment">                 * Easiest case - empty tree. We ca> just takeo/spa>28i497o/a>ospa> class="comment">                 * whatever window of free bits we wa>t.o/spa>28i498o/a>ospa> class="comment">                 */o/spa>28i499o/a>3.ti i          oa href="+code=cle>" class="sref">cle>o/a> =ioa href="+code=ocfs2_resmap_find_free_bits" class="sref">ocfs2_resmap_find_free_bitso/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=wa>ted" class="sref">wa>tedo/a>, oa href="+code=goal" class="sref">goalo/a>,8i500o/a>3.ti i       i                                     oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_bitmap_le>" class="sref">m_bitmap_le>o/a> -ioa href="+code=goal" class="sref">goalo/a>,8i501o/a>3.ti i       i                                     &oa href="+code=cstart" class="sref">cstarto/a>, &oa href="+code=cle>" class="sref">cle>o/a>);8i502o/a>8i503o/a>3.ti i          ospa> class="comment">/*o/spa>28i504o/a>ospa> class="comment">                 * This should never happen -ithe local alloc windowo/spa>28i505o/a>ospa> class="comment">                 * will always have free bits whe> we're called.o/spa>28i506o/a>ospa> class="comment">                 */o/spa>28i507o/a>3.ti i       i  oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(oa href="+code=goal" class="sref">goalo/a> == 0 &&ioa href="+code=cle>" class="sref">cle>o/a> == 0);8i508o/a>8i509o/a>3.ti i          if (oa href="+code=cle>" class="sref">cle>o/a> == 0)8i510o/a>3.ti i       i          return;8i511o/a>8i512o/a>3.ti i          oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a> =ioa href="+code=cstart" class="sref">cstarto/a>;8i513o/a>3.ti i          oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a> =ioa href="+code=cle>" class="sref">cle>o/a>;8i514o/a>8i515o/a>3.ti i       i  oa href="+code=ocfs2_resv_insert" class="sref">ocfs2_resv_inserto/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>);8i516o/a>3.ti i       i  return;8i517o/a>3.ti i  }8i518o/a>8i519o/a>3.ti i  oa href="+code=prev_resv" class="sref">prev_resvo/a> =ioa href="+code=ocfs2_find_resv_lhs" class="sref">ocfs2_find_resv_lhso/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=goal" class="sref">goalo/a>);8i52"17a>8i521o/a>3.ti i  if (oa href="+code=prev_resv" class="sref">prev_resvo/a> ==ioa href="+code=NULL" class="sref">NULLo/a>) {8i522o/a>3.ti i          ospa> class="comment">/*o/spa>28i523o/a>ospa> class="comment">                 * A NULL here means that the search code couldn'to/spa>28i524o/a>ospa> class="comment">                 * find a window that starts before goal.o/spa>28i525o/a>ospa> class="comment">                 *o/spa>28i526o/a>ospa> class="comment">                 * However, we ca> take the first window after goal,o/spa>28i527o/a>ospa> class="comment">                 * which is also by defini2e=>, the leftmost window i>o/spa>28i528o/a>ospa> class="comment">                 * the entire tree. If we ca> find free bits in theo/spa>28i529o/a>ospa> class="comment">                 * gap betwee> goal and the LHS window, then theo/spa>28i530o/a>ospa> class="comment">                 * reserva2e=> ca> safely be placed there.o/spa>28i531o/a>ospa> class="comment">                 *o/spa>28i532o/a>ospa> class="comment">                 * Otherwise we fall back to a linear search, checkingo/spa>28i533o/a>ospa> class="comment">                 * the gaps in betwee> windows for a place too/spa>28i534o/a>ospa> class="comment">                 * alloca2e.o/spa>28i535o/a>ospa> class="comment">                 */o/spa>28i536o/a>8i537o/a>3.ti i       i  oa href="+code=next" class="sref">nexto/a> =ioa href="+code=rb_first" class="sref">rb_firsto/a>(oa href="+code=root" class="sref">rooto/a>);8i538o/a>3.ti i       i  oa href="+code=next_resv" class="sref">next_resvo/a> =ioa href="+code=rb_entry" class="sref">rb_entryo/a>(oa href="+code=next" class="sref">nexto/a>, structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>,8i539o/a>3.ti i                  i i       i  oa href="+code=r_node" class="sref">r_nodeo/a>);8i54"17a>8i541o/a>3.ti i       i  ospa> class="comment">/*o/spa>28i542o/a>ospa> class="comment">                 * The search should never return such a window. (seeo/spa>28i543o/a>ospa> class="comment">                 * comment aboveo/spa>28i544o/a>ospa> class="comment">                 */o/spa>28i545o/a>3.ti i       i  if (oa href="+code=next_resv" class="sref">next_resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>3<=ioa href="+code=goal" class="sref">goalo/a>) {8i546o/a>3.ti i       i       i  oa href="+code=mlog" class="sref">mlogo/a>(oa href="+code=ML_ERROR" class="sref">ML_ERRORo/a>, ospa> class="string">"goal: %u next_resv: start %u le> %u\n"o/spa>2,8i547o/a>3.ti i       i    i       i  oa href="+code=goal" class="sref">goalo/a>, oa href="+code=next_resv" class="sref">next_resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>, oa href="+code=next_resv" class="sref">next_resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>);8i548o/a>3.ti i       i          oa href="+code=ocfs2_dump_resv" class="sref">ocfs2_dump_resvo/a>(oa href="+code=resmap" class="sref">resmapo/a>);8i549o/a>3.ti i                  oa href="+code=BUG" class="sref">BUGo/a>();8i550o/a>3.ti i       i  }8i551o/a>8i552o/a>3.ti i          oa href="+code=cle>" class="sref">cle>o/a> =ioa href="+code=ocfs2_resmap_find_free_bits" class="sref">ocfs2_resmap_find_free_bitso/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=wa>ted" class="sref">wa>tedo/a>, oa href="+code=goal" class="sref">goalo/a>,8i553o/a>3.ti i                  ti i       i    i       i  oa href="+code=next_resv" class="sref">next_resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>3-ioa href="+code=goal" class="sref">goalo/a>,8i554o/a>3.ti i                                             &oa href="+code=cstart" class="sref">cstarto/a>, &oa href="+code=cle>" class="sref">cle>o/a>);8i555o/a>3.ti i       i  if (oa href="+code=cle>" class="sref">cle>o/a>) {8i556o/a>3.ti i       i       i  oa href="+code=best_le>" class="sref">best_le>o/a> =ioa href="+code=cle>" class="sref">cle>o/a>;8i557o/a>3.ti i       i       i  oa href="+code=best_start" class="sref">best_starto/a> =ioa href="+code=cstart" class="sref">cstarto/a>;8i558o/a>3.ti i       i          if (oa href="+code=best_le>" class="sref">best_le>o/a> == oa href="+code=wa>ted" class="sref">wa>tedo/a>)8i559o/a>3.ti i                  i i     gotoioa href="+code=out_insert" class="sref">out_inserto/a>;8i560o/a>3.ti i       i  }8i561o/a>8i562o/a>3.ti i          oa href="+code=prev_resv" class="sref">prev_resvo/a> =ioa href="+code=next_resv" class="sref">next_resvo/a>;8i563o/a>3.ti i          oa href="+code=next_resv" class="sref">next_resvo/a> =ioa href="+code=NULL" class="sref">NULLo/a>;8i564o/a>3.ti i  }8i565o/a>8i566o/a>3.ti i  oa href="+code=trace_ocfs2_resv_find_window_prev" class="sref">trace_ocfs2_resv_find_window_prevo/a>(oa href="+code=prev_resv" class="sref">prev_resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>,8i567o/a>3.ti i       i    i                    i  oa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=prev_resv" class="sref">prev_resvo/a>));8i568o/a>8i569o/a>3.ti i  oa href="+code=prev" class="sref">prevo/a> =i&oa href="+code=prev_resv" class="sref">prev_resvo/a>->oa href="+code=r_node" class="sref">r_nodeo/a>;8i57"17a>8i571o/a>3.ti i  ospa> class="comment">/* Now we do a linear search for a window, starting at 'prev_rsv' */o/spa>28i572o/a>3.ti i  while (1) {8i573o/a>3.ti i          oa href="+code=next" class="sref">nexto/a> =ioa href="+code=rb_next" class="sref">rb_nexto/a>(oa href="+code=prev" class="sref">prevo/a>);8i574o/a>3.ti i          if (oa href="+code=next" class="sref">nexto/a>) {8i575o/a>3.ti i       i          oa href="+code=next_resv" class="sref">next_resvo/a> =ioa href="+code=rb_entry" class="sref">rb_entryo/a>(oa href="+code=next" class="sref">nexto/a>,8i576o/a>3.ti i       i       i                       structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>,8i577o/a>3.ti i       i    i                    i     oa href="+code=r_node" class="sref">r_nodeo/a>);8i578o/a>8i579o/a>3.ti i                  oa href="+code=gap_start" class="sref">gap_starto/a> =ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=prev_resv" class="sref">prev_resvo/a>) +i1;8i580o/a>3.ti i       i          oa href="+code=gap_end" class="sref">gap_endo/a> =ioa href="+code=next_resv" class="sref">next_resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>3-i1;8i581o/a>3.ti i       i          oa href="+code=gap_le>" class="sref">gap_le>o/a> =ioa href="+code=gap_end" class="sref">gap_endo/a> -ioa href="+code=gap_start" class="sref">gap_starto/a> +i1;8i582o/a>3.ti i          } else {8i583o/a>3.ti i                  ospa> class="comment">/*o/spa>28i584o/a>ospa> class="comment">                         * We're at the rightmost edge of theo/spa>28i585o/a>ospa> class="comment">                         * tree. See if a reserva2e=> betwee> thiso/spa>28i586o/a>ospa> class="comment">                         * window and the end of the bitmap will work.o/spa>28i587o/a>ospa> class="comment">                         */o/spa>28i588o/a>3.ti i       i          oa href="+code=gap_start" class="sref">gap_starto/a> =ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=prev_resv" class="sref">prev_resvo/a>) +i1;8i589o/a>3.ti i                  oa href="+code=gap_le>" class="sref">gap_le>o/a> =ioa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_bitmap_le>" class="sref">m_bitmap_le>o/a> -ioa href="+code=gap_start" class="sref">gap_starto/a>;8i590o/a>3.ti i       i          oa href="+code=gap_end" class="sref">gap_endo/a> =ioa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_bitmap_le>" class="sref">m_bitmap_le>o/a> -i1;8i591o/a>3.ti i       i  }8i592o/a>8i593o/a>3.ti i          oa href="+code=trace_ocfs2_resv_find_window_next" class="sref">trace_ocfs2_resv_find_window_nexto/a>(oa href="+code=next" class="sref">nexto/a> ?ioa href="+code=next_resv" class="sref">next_resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>: -1,8i594o/a>3.ti i                                  oa href="+code=next" class="sref">nexto/a> ?ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=next_resv" class="sref">next_resvo/a>) : -1);8i595o/a>3.ti i       i  ospa> class="comment">/*o/spa>28i596o/a>ospa> class="comment">                 * No need to check this gap if we have already foundo/spa>28i597o/a>ospa> class="comment">                 * a larger rege=> of free bits.o/spa>28i598o/a>ospa> class="comment">                 */o/spa>28i599o/a>3.ti i          if (oa href="+code=gap_le>" class="sref">gap_le>o/a> <=ioa href="+code=best_le>" class="sref">best_le>o/a>)8i600o/a>3.ti i       i          gotoioa href="+code=next_resv" class="sref">next_resvo/a>;8i601o/a>8i602o/a>3.ti i          oa href="+code=cle>" class="sref">cle>o/a> =ioa href="+code=ocfs2_resmap_find_free_bits" class="sref">ocfs2_resmap_find_free_bitso/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=wa>ted" class="sref">wa>tedo/a>, oa href="+code=gap_start" class="sref">gap_starto/a>,8i603o/a>3.ti i                                             oa href="+code=gap_le>" class="sref">gap_le>o/a>, &oa href="+code=cstart" class="sref">cstarto/a>, &oa href="+code=cle>" class="sref">cle>o/a>);8i604o/a>3.ti i          if (oa href="+code=cle>" class="sref">cle>o/a> == oa href="+code=wa>ted" class="sref">wa>tedo/a>) {8i605o/a>3.ti i       i          oa href="+code=best_le>" class="sref">best_le>o/a> =ioa href="+code=cle>" class="sref">cle>o/a>;8i606o/a>3.ti i       i       i  oa href="+code=best_start" class="sref">best_starto/a> =ioa href="+code=cstart" class="sref">cstarto/a>;8i607o/a>3.ti i       i          gotoioa href="+code=out_insert" class="sref">out_inserto/a>;8i608o/a>3.ti i       i  } else if (oa href="+code=cle>" class="sref">cle>o/a> >ioa href="+code=best_le>" class="sref">best_le>o/a>) {8i609o/a>3.ti i                  oa href="+code=best_le>" class="sref">best_le>o/a> =ioa href="+code=cle>" class="sref">cle>o/a>;8i610o/a>3.ti i       i          oa href="+code=best_start" class="sref">best_starto/a> =ioa href="+code=cstart" class="sref">cstarto/a>;8i611o/a>3.ti i       i  }8i612o/a>8i613o/a>oa href="+code=next_resv" class="sref">next_resvo/a>:8i614o/a>3.ti i          if (!oa href="+code=next" class="sref">nexto/a>)8i615o/a>3.ti i       i          break;8i616o/a>8i617o/a>3.ti i       i  oa href="+code=prev" class="sref">prevo/a> =ioa href="+code=next" class="sref">nexto/a>;8i618o/a>3.ti i       i  oa href="+code=prev_resv" class="sref">prev_resvo/a> =ioa href="+code=rb_entry" class="sref">rb_entryo/a>(oa href="+code=prev" class="sref">prevo/a>,3structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>,8i619o/a>3.ti i                  i i       i  oa href="+code=r_node" class="sref">r_nodeo/a>);8i620o/a>3.ti i  }8i621o/a>8i622o/a>oa href="+code=out_insert" class="sref">out_inserto/a>:8i623o/a>3.ti i  if (oa href="+code=best_le>" class="sref">best_le>o/a>) {8i624o/a>3.ti i          oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a> =ioa href="+code=best_start" class="sref">best_starto/a>;8i625o/a>3.ti i       i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a> =ioa href="+code=best_le>" class="sref">best_le>o/a>;8i626o/a>3.ti i       i  oa href="+code=ocfs2_resv_insert" class="sref">ocfs2_resv_inserto/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>);8i627o/a>3.ti i  }8i628o/a>}8i629o/a>8i630o/a>sta2ec voidioa href="+code=ocfs2_cannibalize_resv" class="sref">ocfs2_cannibalize_resvo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i631o/a>3.ti i       i                     structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>,8i632o/a>3.ti i                             unsigned intioa href="+code=wa>ted" class="sref">wa>tedo/a>)8i633o/a>{8i634o/a>3.ti i  structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=lru_resv" class="sref">lru_resvo/a>;8i635o/a>3.ti i  intioa href="+code=tmpwindow" class="sref">tmpwindowo/a> =i!!(oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_flags" class="sref">r_flagso/a> &ioa href="+code=OCFS2_RESV_FLAG_TMP" class="sref">OCFS2_RESV_FLAG_TMPo/a>);8i636o/a>3.ti i  unsigned intioa href="+code=min_bits" class="sref">min_bitso/a>;8i637o/a>8i638o/a>3.ti i  if (!oa href="+code=tmpwindow" class="sref">tmpwindowo/a>)8i639o/a>3.ti i          oa href="+code=min_bits" class="sref">min_bitso/a> =ioa href="+code=ocfs2_resv_window_bits" class="sref">ocfs2_resv_window_bitso/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>) >>i1;8i640o/a>3.ti i  else8i641o/a>3.ti i       i  oa href="+code=min_bits" class="sref">min_bitso/a> =ioa href="+code=wa>ted" class="sref">wa>tedo/a>; ospa> class="comment">/* We at know the temp window will use allo/spa>28i642o/a>ospa> class="comment">                                    * of these bits */o/spa>28i643o/a>8i644o/a>3.ti i  ospa> class="comment">/*o/spa>28i645o/a>ospa> class="comment">         * Take the first reserva2e=> off the LRU as our 'target'. Weo/spa>28i646o/a>ospa> class="comment">         * don't try to be smart about it. There might be a case foro/spa>28i647o/a>ospa> class="comment">         * searching based => size but I don't have enough data to beo/spa>28i648o/a>ospa> class="comment">         * sure. --Mark (3/16/2010)o/spa>28i649o/a>ospa> class="comment">         */o/spa>28i650o/a>3.ti i  oa href="+code=lru_resv" class="sref">lru_resvo/a> =ioa href="+code=list_first_entry" class="sref">list_first_entryo/a>(&oa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_lru" class="sref">m_lruo/a>,8i651o/a>3.ti i       i                      structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>, oa href="+code=r_lru" class="sref">r_lruo/a>);8i652o/a>8i653o/a>3.ti i  oa href="+code=trace_ocfs2_cannibalize_resv_begi>" class="sref">trace_ocfs2_cannibalize_resv_begi>o/a>(oa href="+code=lru_resv" class="sref">lru_resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>,8i654o/a>3.ti i                                     oa href="+code=lru_resv" class="sref">lru_resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>,8i655o/a>3.ti i       i                             oa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=lru_resv" class="sref">lru_resvo/a>));8i656o/a>8i657o/a>3.ti i  ospa> class="comment">/*o/spa>28i658o/a>ospa> class="comment">         * Cannibalize (some or all) of the target reserva2e=> ando/spa>28i659o/a>ospa> class="comment">         * feed it to the current window.o/spa>28i660o/a>ospa> class="comment">         */o/spa>28i661o/a>3.ti i  if (oa href="+code=lru_resv" class="sref">lru_resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a> <=ioa href="+code=min_bits" class="sref">min_bitso/a>) {8i662o/a>3.ti i          ospa> class="comment">/*o/spa>28i663o/a>ospa> class="comment">                 * Discard completely if size is less than or equal to ao/spa>28i664o/a>ospa> class="comment">                 * reasonable threshold - 50% of window bits for n=> temporaryo/spa>28i665o/a>ospa> class="comment">                 * windows.o/spa>28i666o/a>ospa> class="comment">                 */o/spa>28i667o/a>3.ti i       i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a> =ioa href="+code=lru_resv" class="sref">lru_resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>;8i668o/a>3.ti i       i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a> =ioa href="+code=lru_resv" class="sref">lru_resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>;8i669o/a>8i670o/a>3.ti i       i  oa href="+code=__ocfs2_resv_discard" class="sref">__ocfs2_resv_discardo/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=lru_resv" class="sref">lru_resvo/a>);8i671o/a>3.ti i  } else {8i672o/a>3.ti i          unsigned intioa href="+code=shrink" class="sref">shrinko/a>;8i673o/a>3.ti i          if (oa href="+code=tmpwindow" class="sref">tmpwindowo/a>)8i674o/a>3.ti i               i  oa href="+code=shrink" class="sref">shrinko/a> =ioa href="+code=min_bits" class="sref">min_bitso/a>;8i675o/a>3.ti i       i  else8i676o/a>3.ti i       i       i  oa href="+code=shrink" class="sref">shrinko/a> =ioa href="+code=lru_resv" class="sref">lru_resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a> / 2;8i677o/a>8i678o/a>3.ti i       i  oa href="+code=lru_resv" class="sref">lru_resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a> -=ioa href="+code=shrink" class="sref">shrinko/a>;8i679o/a>8i680o/a>3.ti i       i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a> =ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=lru_resv" class="sref">lru_resvo/a>) +i1;8i681o/a>3.ti i       i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a> =ioa href="+code=shrink" class="sref">shrinko/a>;8i682o/a>3.ti i  }8i683o/a>8i684o/a>3.ti i  oa href="+code=trace_ocfs2_cannibalize_resv_end" class="sref">trace_ocfs2_cannibalize_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>, oa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>),8i685o/a>3.ti i       i                           oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>, oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_start" class="sref">r_last_starto/a>,8i686o/a>3.ti i       i       i                   oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_le>" class="sref">r_last_le>o/a>);8i687o/a>8i688o/a>3.ti i  oa href="+code=ocfs2_resv_insert" class="sref">ocfs2_resv_inserto/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>);8i689o/a>}8i69"17a>8i691o/a>sta2ec voidioa href="+code=ocfs2_resv_find_window" class="sref">ocfs2_resv_find_windowo/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i692o/a>3.ti i                             structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>,8i693o/a>3.ti i                             unsigned intioa href="+code=wa>ted" class="sref">wa>tedo/a>)8i694o/a>{8i695o/a>3.ti i  unsigned intioa href="+code=goal" class="sref">goalo/a> =i0;8i696o/a>8i697o/a>3.ti i  oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(!oa href="+code=ocfs2_resv_empty" class="sref">ocfs2_resv_emptyo/a>(oa href="+code=resv" class="sref">resvo/a>));8i698o/a>8i699o/a>3.ti i  ospa> class="comment">/*o/spa>28i700o/a>ospa> class="comment">         * Begi> by trying to get a window as close to the previouso/spa>28i701o/a>ospa> class="comment">         * one as possible. Using the most recent alloca2e=> as ao/spa>28i702o/a>ospa> class="comment">         * start goal makes sense.o/spa>28i703o/a>ospa> class="comment">         */o/spa>28i704o/a>3.ti i  if (oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_le>" class="sref">r_last_le>o/a>) {8i705o/a>3.ti i       i  oa href="+code=goal" class="sref">goalo/a> =ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_start" class="sref">r_last_starto/a> + oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_le>" class="sref">r_last_le>o/a>;8i706o/a>3.ti i       i  if (oa href="+code=goal" class="sref">goalo/a> >=ioa href="+code=resmap" class="sref">resmapo/a>->oa href="+code=m_bitmap_le>" class="sref">m_bitmap_le>o/a>)8i707o/a>3.ti i       i          oa href="+code=goal" class="sref">goalo/a> =i0;8i708o/a>3.ti i  }8i709o/a>8i710o/a>3.ti i  oa href="+code=__ocfs2_resv_find_window" class="sref">__ocfs2_resv_find_windowo/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>, oa href="+code=goal" class="sref">goalo/a>,ioa href="+code=wa>ted" class="sref">wa>tedo/a>);8i711o/a>8i712o/a>3.ti i  ospa> class="comment">/* Search from last alloc didn't work, try once more from begi>ning. */o/spa>28i713o/a>3.ti i  if (oa href="+code=ocfs2_resv_empty" class="sref">ocfs2_resv_emptyo/a>(oa href="+code=resv" class="sref">resvo/a>) &&ioa href="+code=goal" class="sref">goalo/a> !=i0)8i714o/a>3.ti i          oa href="+code=__ocfs2_resv_find_window" class="sref">__ocfs2_resv_find_windowo/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>, 0,ioa href="+code=wa>ted" class="sref">wa>tedo/a>);8i715o/a>8i716o/a>3.ti i  if (oa href="+code=ocfs2_resv_empty" class="sref">ocfs2_resv_emptyo/a>(oa href="+code=resv" class="sref">resvo/a>)) {8i717o/a>3.ti i       i  ospa> class="comment">/*o/spa>28i718o/a>ospa> class="comment">                 * Still empty? Pull oldest one off the LRU, remove it fromo/spa>28i719o/a>ospa> class="comment">                 * tree, put this one i> it's place.o/spa>28i720o/a>ospa> class="comment">                 */o/spa>28i721o/a>3.ti i       i  oa href="+code=ocfs2_cannibalize_resv" class="sref">ocfs2_cannibalize_resvo/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>, oa href="+code=wa>ted" class="sref">wa>tedo/a>);8i722o/a>3.ti i  }8i723o/a>8i724o/a>3.ti i  oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(oa href="+code=ocfs2_resv_empty" class="sref">ocfs2_resv_emptyo/a>(oa href="+code=resv" class="sref">resvo/a>));8i725o/a>}8i726o/a>8i727o/a>intioa href="+code=ocfs2_resmap_resv_bits" class="sref">ocfs2_resmap_resv_bitso/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i728o/a>3.ti i       i             structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>,8i729o/a>3.ti i                  i iinti*oa href="+code=cstart" class="sref">cstarto/a>, inti*oa href="+code=cle>" class="sref">cle>o/a>)8i730o/a>{8i731o/a>3.ti i  if (oa href="+code=resv" class="sref">resvo/a> == oa href="+code=NULL" class="sref">NULLo/a> ||ioa href="+code=ocfs2_resmap_disabled" class="sref">ocfs2_resmap_disabledo/a>(oa href="+code=resmap" class="sref">resmapo/a>))8i732o/a>3.ti i          return -oa href="+code=ENOSPC" class="sref">ENOSPCo/a>;8i733o/a>8i734o/a>3.ti i  oa href="+code=spin_lock" class="sref">spin_locko/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i735o/a>8i736o/a>3.ti i  if (oa href="+code=ocfs2_resv_empty" class="sref">ocfs2_resv_emptyo/a>(oa href="+code=resv" class="sref">resvo/a>)) {8i737o/a>3.ti i       i  ospa> class="comment">/*o/spa>28i738o/a>ospa> class="comment">                 * We don't wa>t to over-alloca2e for temporaryo/spa>28i739o/a>ospa> class="comment">                 * windows. Otherwise, we run the risk of fragmenting theo/spa>28i740o/a>ospa> class="comment">                 * alloca2e=> space.o/spa>28i741o/a>ospa> class="comment">                 */o/spa>28i742o/a>3.ti i          unsigned intioa href="+code=wa>ted" class="sref">wa>tedo/a> =ioa href="+code=ocfs2_resv_window_bits" class="sref">ocfs2_resv_window_bitso/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>);8i743o/a>8i744o/a>3.ti i          if ((oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_flags" class="sref">r_flagso/a> &ioa href="+code=OCFS2_RESV_FLAG_TMP" class="sref">OCFS2_RESV_FLAG_TMPo/a>) ||ioa href="+code=wa>ted" class="sref">wa>tedo/a> <i*oa href="+code=cle>" class="sref">cle>o/a>)8i745o/a>3.ti i       i          oa href="+code=wa>ted" class="sref">wa>tedo/a> =i*oa href="+code=cle>" class="sref">cle>o/a>;8i746o/a>8i747o/a>3.ti i       i  ospa> class="comment">/*o/spa>28i748o/a>ospa> class="comment">                 * Try to get a window here. If it works, we must fallo/spa>28i749o/a>ospa> class="comment">                 * through and test the bitmap . This avoids someo/spa>28i750o/a>ospa> class="comment">                 * ping-ponging of windows due to non-reserved spaceo/spa>28i751o/a>ospa> class="comment">                 * being alloca2e=> before we i>itialize a window foro/spa>28i752o/a>ospa> class="comment">                 * that i>ode.o/spa>28i753o/a>ospa> class="comment">                 */o/spa>28i754o/a>3.ti i          oa href="+code=ocfs2_resv_find_window" class="sref">ocfs2_resv_find_windowo/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>, oa href="+code=wa>ted" class="sref">wa>tedo/a>);8i755o/a>3.ti i       i  oa href="+code=trace_ocfs2_resmap_resv_bits" class="sref">trace_ocfs2_resmap_resv_bitso/a>(oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>, oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>);8i756o/a>3.ti i  }8i757o/a>8i758o/a>3.ti i  oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(oa href="+code=ocfs2_resv_empty" class="sref">ocfs2_resv_emptyo/a>(oa href="+code=resv" class="sref">resvo/a>));8i759o/a>8i760o/a>3.ti i  *oa href="+code=cstart" class="sref">cstarto/a> =ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>;8i761o/a>3.ti i  *oa href="+code=cle>" class="sref">cle>o/a> =ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>;8i762o/a>8i763o/a>3.ti i  oa href="+code=spin_unlock" class="sref">spin_unlocko/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i764o/a>3.ti i  return 0;8i765o/a>}8i766o/a>8i767o/a>sta2ec void8i768o/a>3.ti i  oa href="+code=ocfs2_adjust_resv_from_alloc" class="sref">ocfs2_adjust_resv_from_alloco/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i769o/a>3.ti i                  i i       i  structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>,8i770o/a>3.ti i       i                       unsigned intioa href="+code=start" class="sref">starto/a>, unsigned intioa href="+code=end" class="sref">endo/a>)8i771o/a>{8i772o/a>3.ti i  unsigned intioa href="+code=rhs" class="sref">rhso/a> =i0;8i773o/a>3.ti i  unsigned intioa href="+code=old_end" class="sref">old_endo/a> =ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>);8i774o/a>8i775o/a>3.ti i  oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(oa href="+code=start" class="sref">starto/a> !=ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a> ||ioa href="+code=old_end" class="sref">old_endo/a> <ioa href="+code=end" class="sref">endo/a>);8i776o/a>8i777o/a>3.ti i  ospa> class="comment">/*o/spa>28i778o/a>ospa> class="comment">         * Completely used? We ca> remove it then.o/spa>28i779o/a>ospa> class="comment">         */o/spa>28i780o/a>3.ti i  if (oa href="+code=old_end" class="sref">old_endo/a> ==ioa href="+code=end" class="sref">endo/a>) {8i781o/a>3.ti i       i  oa href="+code=__ocfs2_resv_discard" class="sref">__ocfs2_resv_discardo/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>);8i782o/a>3.ti i          return;8i783o/a>3.ti i  }8i784o/a>8i785o/a>3.ti i  oa href="+code=rhs" class="sref">rhso/a> =ioa href="+code=old_end" class="sref">old_endo/a> -ioa href="+code=end" class="sref">endo/a>;8i786o/a>8i787o/a>3.ti i  ospa> class="comment">/*o/spa>28i788o/a>ospa> class="comment">         * This should have been trapped above.o/spa>28i789o/a>ospa> class="comment">         */o/spa>28i790o/a>3.ti i  oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(oa href="+code=rhs" class="sref">rhso/a> ==i0);8i791o/a>8i792o/a>3.ti i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a> =ioa href="+code=end" class="sref">endo/a> +i1;8i793o/a>3.ti i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a> =ioa href="+code=old_end" class="sref">old_endo/a> -ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a> +i1;8i794o/a>}8i795o/a>8i796o/a>voidioa href="+code=ocfs2_resmap_claimed_bits" class="sref">ocfs2_resmap_claimed_bitso/a>(structioa href="+code=ocfs2_reserva2e=>_map" class="sref">ocfs2_reserva2e=>_mapo/a>3*oa href="+code=resmap" class="sref">resmapo/a>,8i797o/a>3.ti i       i                 structioa href="+code=ocfs2_alloc_reserva2e=>" class="sref">ocfs2_alloc_reserva2e=>o/a>3*oa href="+code=resv" class="sref">resvo/a>,8i798o/a>3.ti i       i              i  oa href="+code=u32" class="sref">u32o/a>3oa href="+code=cstart" class="sref">cstarto/a>, oa href="+code=u32" class="sref">u32o/a>3oa href="+code=cle>" class="sref">cle>o/a>)8i799o/a>{8i800o/a>3.ti i  unsigned intioa href="+code=cend" class="sref">cendo/a> =ioa href="+code=cstart" class="sref">cstarto/a> + oa href="+code=cle>" class="sref">cle>o/a> -i1;8i801o/a>8i802o/a>3.ti i  if (oa href="+code=resmap" class="sref">resmapo/a> == oa href="+code=NULL" class="sref">NULLo/a> ||ioa href="+code=ocfs2_resmap_disabled" class="sref">ocfs2_resmap_disabledo/a>(oa href="+code=resmap" class="sref">resmapo/a>))8i803o/a>3.ti i          return;8i804o/a>8i805o/a>3.ti i  if (oa href="+code=resv" class="sref">resvo/a> == oa href="+code=NULL" class="sref">NULLo/a>)8i806o/a>3.ti i       i  return;8i807o/a>8i808o/a>3.ti i  oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(oa href="+code=cstart" class="sref">cstarto/a> !=ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>);8i809o/a>8i810o/a>3.ti i  oa href="+code=spin_lock" class="sref">spin_locko/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i811o/a>8i812o/a>3.ti i  oa href="+code=trace_ocfs2_resmap_claimed_bits_begi>" class="sref">trace_ocfs2_resmap_claimed_bits_begi>o/a>(oa href="+code=cstart" class="sref">cstarto/a>, oa href="+code=cend" class="sref">cendo/a>, oa href="+code=cle>" class="sref">cle>o/a>, oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>,8i813o/a>3.ti i                                     i  oa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>), oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>,8i814o/a>3.ti i                                     i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_start" class="sref">r_last_starto/a>,8i815o/a>3.ti i       i                             i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_le>" class="sref">r_last_le>o/a>);8i816o/a>8i817o/a>3.ti i  oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(oa href="+code=cstart" class="sref">cstarto/a> <ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>);8i818o/a>3.ti i  oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(oa href="+code=cstart" class="sref">cstarto/a> >ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>));8i819o/a>3.ti i  oa href="+code=BUG_ON" class="sref">BUG_ONo/a>(oa href="+code=cend" class="sref">cendo/a> >ioa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>));8i82"17a>8i821o/a>3.ti i  oa href="+code=ocfs2_adjust_resv_from_alloc" class="sref">ocfs2_adjust_resv_from_alloco/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>, oa href="+code=cstart" class="sref">cstarto/a>, oa href="+code=cend" class="sref">cendo/a>);8i822o/a>3.ti i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_start" class="sref">r_last_starto/a> =ioa href="+code=cstart" class="sref">cstarto/a>;8i823o/a>3.ti i  oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_le>" class="sref">r_last_le>o/a> =ioa href="+code=cle>" class="sref">cle>o/a>;8i824o/a>8i825o/a>3.ti i  ospa> class="comment">/*o/spa>28i826o/a>ospa> class="comment">         * May have been discarded above fromo/spa>28i827o/a>ospa> class="comment">         * ocfs2_adjust_resv_from_alloc().o/spa>28i828o/a>ospa> class="comment">         */o/spa>28i829o/a>3.ti i  if (!oa href="+code=ocfs2_resv_empty" class="sref">ocfs2_resv_emptyo/a>(oa href="+code=resv" class="sref">resvo/a>))8i830o/a>3.ti i       i  oa href="+code=ocfs2_resv_mark_lru" class="sref">ocfs2_resv_mark_lruo/a>(oa href="+code=resmap" class="sref">resmapo/a>, oa href="+code=resv" class="sref">resvo/a>);8i831o/a>8i832o/a>3.ti i  oa href="+code=trace_ocfs2_resmap_claimed_bits_end" class="sref">trace_ocfs2_resmap_claimed_bits_endo/a>(oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_start" class="sref">r_starto/a>, oa href="+code=ocfs2_resv_end" class="sref">ocfs2_resv_endo/a>(oa href="+code=resv" class="sref">resvo/a>),8i833o/a>3.ti i                                     ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_le>" class="sref">r_le>o/a>, oa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_start" class="sref">r_last_starto/a>,8i834o/a>3.ti i                                     ioa href="+code=resv" class="sref">resvo/a>->oa href="+code=r_last_le>" class="sref">r_last_le>o/a>);8i835o/a>8i836o/a>3.ti i  oa href="+code=ocfs2_check_resmap" class="sref">ocfs2_check_resmapo/a>(oa href="+code=resmap" class="sref">resmapo/a>);8i837o/a>8i838o/a>3.ti i  oa href="+code=spin_unlock" class="sref">spin_unlocko/a>(&oa href="+code=resv_lock" class="sref">resv_locko/a>);8i839o/a>}8i840o/a>o/pre>o/div>


o/div>