linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roman Mamedov <rm@romanrm.net>
To: Timofey Titovets <nefelim4ag@gmail.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: swapfile on btrfs, temporary solution for wiki
Date: Fri, 25 Oct 2013 16:35:46 +0600	[thread overview]
Message-ID: <20131025163546.4cf3291a@natsu> (raw)
In-Reply-To: <CAGqmi74F9GurJL73qtU4JG+Fi4RbXE7tiaO1uEQqEY2ym278eA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1375 bytes --]

On Thu, 24 Oct 2013 23:52:01 +0300
Timofey Titovets <nefelim4ag@gmail.com> wrote:

> Hello, i suggest temporary solution to use swap file under btrfs.
> I test it, and it work good.
> 
> I invent simple the way, how create and using swap file, just see
> following sh code:
> 
> swapfile=$(losetup -f) #free loop device
> truncate -s 8G /swap   #create 8G sparse swap file
> losetup $swapfile /swap #mount file to loop
> mkswap  $swapfile
> swapon  $swapfile
> 
> i just adding this to rc.local and this work good.
> May be, add it to btrfs Wiki as temporary solution to using swap file?

I always thought Btrfs does not allow swap files on purpose, because it is not
deadlock-proof when used in the swapping context.

Imagine you try swapping out pages to free up some memory, and in the process
Btrfs needs to allocate some memory to actually perform the write, the kernel
says "Sure, but for that we need to swap out some more pages..." You see where
that goes.

Same issue is possible with swap on other complex filesystems an example
being networked ones like NFS and SMB/CIFS.

It might work for some time (or even work 99% of time), but you still may be
endangering your system to a possibility of a lock-up, and certainly adding
that to any Wiki/FAQ/website as "the solution" might not be the best choice.

-- 
With respect,
Roman

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  parent reply	other threads:[~2013-10-25 10:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-21 20:37 swapfile on btrfs, temporary solution for wiki Тимофей Титовец
2013-10-24 20:52 ` Timofey Titovets
2013-10-25  9:36   ` dima
2013-10-25 10:35   ` Roman Mamedov [this message]
2013-10-25 10:44     ` Hugo Mills
2013-10-26  9:28       ` karim.allah.ahmed
2013-10-26  9:30       ` karim.allah.ahmed
2013-10-26 11:50         ` Hugo Mills
2013-10-26 14:11         ` Duncan
2013-10-30 15:54   ` David Sterba
2013-10-30 20:11     ` Timofey Titovets
2013-10-30 20:12       ` Timofey Titovets

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131025163546.4cf3291a@natsu \
    --to=rm@romanrm.net \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nefelim4ag@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).